Monday, June 15, 2009

Hello World of Qt

Here, I will create a minimal Qt application, which show the word "Hello World Qt".

environment:
OS: Ubuntu Linux 9.04
Qt SDK 4.5, command line only.

Create a source code, hello.cpp, with the following content. And save in folder "hello".



#include <QApplication>
#include <QtGui>

int main(int
argc, char *argv[])
{
QApplication app(argc, argv);
QLabel *label = new QLabel("Hello World Qt!");
label->show();
return app.exec();
}

hello.cpp


Start Terminal, change to the folder "hello".

Type the following command:

qmake -project
qmake hello.pro
make

Run by the command:

./hello