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)

  • 相关阅读:
    Wooden Sticks(hdu1051)
    Leftmost Digit(hdu1060)(数学题)
    Sum of Remainders(数学题)
    Brain Network (medium)(DFS)
    Brain Network (easy)(并查集水题)
    Collective Mindsets (medium) (逻辑题)
    Collective Mindsets (easy)(逻辑题)
    RMQ with Shifts(线段树)
    Throwing Dice(概率dp)
    圆桌会议
  • 原文地址:https://www.cnblogs.com/hgy413/p/3693725.html
Copyright © 2011-2022 走看看