最好的qt教材及学习笔记集合http://www.qteverywhere.com/learnqt#comment-2890
#include <QtGui/QApplication>
#include <QtGui/qpushbutton>
int main(int argc, char *argv[])
{
QApplication a(argc, argv);
QPushButton hello("hello world,this is yuanlulu./n this is my first QT program",0);
hello.resize(100,20);
hello.show();
return a.exec();
}
我觉得Qt编程主要是对C++的理解。如果你会C++,Qt编程不再话下,只要你掌握信号、槽等概念就可以了。本文 给出一个qt编程的基本流程(经典的hello实例),以此能快速上手qt编程。
1.生成一个工程文件 progen -t app.t -o hello.pro
2.通过Qt Designer设计界面,保存为hello.ui。
3.生成窗体类的头文件和实现文件:
uic -o hello.h hello.ui (hello.h定义类,手动添加一些信号、槽、成员函数、成员数据)
uic -o hello.cpp -impl hello.h hello.ui(hello.cpp定义类中的信号、槽和成员函数的具体实现)
4.编写主函数main(),固定格式。
5.编辑工程文件hello.pro文件,相应位置加入相应文件,固定格式。
6.生成Makefile文件,在LIBS后加“-lm -stdc++”。
7.编译连接整个工程并运行
make
qvfb & ./hello &