qt编程第一例

fortruth posted @ 2008年2月05日 00:21 , 878 阅读

C 书看一阵了,开始qt程序之旅。现在的qt 库已经是4.3.2了。
下例是经典的qt hello 程序。由于qt4 和qt3 存在一定差异,qt4中的QApplication 中没有setMainWidget 方法。从而就不需要app.setMainWidget(&hello) 一行。

#include < qapllication.h >
#include < qpushbutton.h >

int main (int argc, char **argv)
{
QApplication app(argc, argv);

QPushButton hello(”Hello world!”,0);
hello.resize(100,30);

#qt4中 QApplication 中没有setMainWidget 方法
# app.setMainWidget(&hello);

hello.show();
return app.exec();
}

使用qmake 三步走:
fortruth@ubuntu:~/Programming/CPP/Qt$ qmake -project
fortruth@ubuntu:~/Programming/CPP/Qt$ qmake
fortruth@ubuntu:~/Programming/CPP/Qt$ make


登录 *


loading captcha image...
(输入验证码)
or Ctrl+Enter