Qt hello world and qmake
Posted on quarta-feira, abril 8th, 2009 at 15:03Hi all,
I am studying Qt and I want to do some posts about.
So I will start with a simple hello world and talking how to compile its source code.
= main.cpp =
#include <QtGui/QApplication>
#include <QtGui/QLabel>
int main(int argc, char *argv[])
{
/* All Qt application need implements a QApplication */
QApplication app(argc, argv);
/* Here QLabel is the main window! */
QLabel label("Hello, world!");
/* Shows the QLabel */
label.show();
/* Enters the main event loop and waits until exit() is called. */
return app.exec();
}
=
Now you need to create the .pro file with the project’s configurations and dependencies.
To create the .pro file you can just run:
$ qmake -project
The command above will create a .pro file with the same name of the directory where is the source code.
To create the Makefile run:
$ qmake
So to complie the source code run:
$ make
You will see a binary file with the same name of the .pro file.
References:
http://doc.trolltech.com/4.5/classes.html

[...] http://ragner.org/programming-languages/qt/142 [...]