zoukankan      html  css  js  c++  java
  • QT学习1 hello程序

     
    #define QT3_SUPPORT
    #include "hello.h"
    #include <QApplication>//在每一个使用QT的应用程序中都必须使用QApplication,它管理了各种
    //应用程序的广泛资源,比如默认字体和光标
    #include <QPushButton.h>//经典的图形用户界面按钮,QWidget,可以显示一段文本或QPixmap
    
    int main(int argc, char *argv[])
    {
    	QApplication a(argc, argv);//argc是命令行变量的数量,argv是数组,C、C++特征
    
        QPushButton hello("hello Qt");//Caption为hello Qt,使用QPushButton(const QString &text, QWidget *parent=0);构造
       
    	//-------------------------------------------
    	//void QApplication::setMainWidget ( QWidget * mainWidget )
    	//设置应用程序的主窗口部件为hello.
    	//它退出,程序也退出了,这个好像只能在QT3_SUPPORT定义后使用
    	//-------------------------------------------
    	a.setMainWidget(&hello);
    
    	//--------------------------------------------
    	// Shows the widget and its child widgets. 
    	// This function is equivalent to setVisible(true).
    	//--------------------------------------------
    	//hello.show();//当创建一个窗口部件时,它是不可见的,你必须调用show让它可见   
    	hello.setVisible(TRUE);
    
    	return a.exec();//控制转给QT,在exec中,QT接收并处理用户和系统的事件并把它们传给适当的窗口部件
    	
    }


    1.使用QT的应用程序中都必须使用QApplication

    2.QApplication::setMainWidget只有在定义了QT3_SUPPORT才能使用

    3.主窗口部件退出,程序跟着退出

    4.show():让widget和它的子widget都可见,同setVisible(true)

  • 相关阅读:
    linux下解压命令详解
    SSL简介及工作原理
    在CentOS中安装gcc配置c语言开发环境(转)
    JTable表格(隐藏表头)(转)
    一个云平台开源项目Eucalyptus
    「CF645E」 Intellectual Inquiry
    「CERC2017」Donut Drone
    洛谷P3943 星空
    「CSPS 2019」格雷码
    洛谷P3941 入阵曲
  • 原文地址:https://www.cnblogs.com/hgy413/p/3693725.html
Copyright © 2011-2022 走看看