建立第一个Qt4程序

来源:互联网 发布:大智慧软件怎么样 编辑:程序博客网 时间:2024/05/23 11:31

开始学习Qt4编程,记录建立第一个Qt4程序的流程。

1. 编写cpp文件

[root@localhost helloqt]# vim helloqt.cpp

#include <QApplication>#include <QPushButton>int main(int argc, char *argv[]){        QApplication app(argc, argv);        QPushButton pushButton(QObject::tr("Hello Qt!"));        pushButton.show();        QObject::connect(&pushButton,SIGNAL(clicked()),&app,SLOT(quit()));        return app.exec();}

2. 生成pro工程文件

[root@localhost helloqt]# qmake -project

3. 生成makefile文件

[root@localhost helloqt]# qmake helloqt.pro

4. 编译

[root@localhost helloqt]# make

5. 执行

[root@localhost helloqt]# ./helloqt


0 0