Hello World (Qt3)
From qtnode
Here's a Hello World test for Qt3.
(Note: this is for Qt3. If you are using Qt4, check out Hello World)
Contents |
Create a source file
Go into an empty directory and create the following file hello.cpp:
#include <qapplication.h>
#include <qlabel.h>
int main(int argc, char **argv) {
QApplication app(argc, argv);
QLabel *label = new QLabel("Hello World!", 0);
label->show();
return app.exec();
}
Create the project file with qmake
Then run the following command:
prompt> qmake -project -o hello.pro
You will now have a project file named hello.pro. This will be used to create a Makefile.
Create a Makefile with qmake
Simply run qmake once more with no options to create a Makefile:
prompt> qmake
Build your application
Depending on your environment, run the appropriate make command:
prompt> mingw32-make
or
prompt> make
or
prompt> nmake
Run your application
Depending on your Qt configuration, the default build targe will be either in the release or debug directory. Go look for it.
Then you can run it by typing (replace \'s with /'s if on *nix):
prompt> release\hello
or
prompt> debug\hello