QT学习1 hello程序
2011-12-10 14:21
218 查看
#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)
相关文章推荐
- QT学习1 hello程序
- QT学习6:组装丰富的积木!
- qnx学习笔记-QNX使用QT开发应用程序
- QT学习7:1个事物领导另一个
- [原创]opencv学习之配置eclipse&nbsp;QT…
- Qt学习之路(37): Qt容器类之关联存储容器
- 【QT学习】如何分析一个QT类
- Qt学习很好的总结
- QT 官方实例 学习
- Qt学习-----finddialog的代码注释
- qt学习第四课:子类化窗口
- Qt学习11——进度条QProgressBar
- 从零开始学习音视频编程技术(三) 开发环境搭建(Qt4.86手动设置环境,主要就是设置g++和qmake,比较透彻,附下载链接)
- 用 cmake 构建Qt工程(对比qmake进行学习) 转贴
- QT界面学习
- QT学习笔记- eclipse集成的QT designer(总结得不错)
- 学习记录-Qt创建按键菜单
- QT5学习:字符串测试
- QT学习(三)文件操作
- Qt学习:线程的创建和同步