martedì 28 agosto 2012

Creating a Qt application in c++ in Windows

Today i'm posting about the famous GUI library created by nokia: Qt.
This  library provide a cross-platform application and UI framework.
To start programming with this library in windows we need to install first minGW (gcc ported to windows), you can download it here.
At the end of the installation add the minGW/bin folder to your PATH variable, to do this go to
control panel>system>advanced system settings>advanced>environment variables

then select the PATH variable in  the system variables and click edit and add at the end


now to check if everything it's working open the command line and try writing


If it's recognized as a command you've done everything right else try checking this tutorial for the installation.
Now we need to install the Qt library that you can download here.
When you finished downloading, install the library and add the    C:\Qt\4.8.2\bin
to the environment variables just like we have done with the minGW binaries.
When you've done check if everything is working writing in the command line


To start programming create file main.cpp and write this code:

#include <Qt/QApplication.h>
#include <Qt/QWidget.h>

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

    QWidget window;

    window.resize(250, 150);

    return app.exec();

Now open a command line and move to the folder that contains the file using cd command and then write this in the command line to compile the file:

qmake -project

If there's no error in your code or in the environment variables you will find the compiled file in the debug folder.

I hope you like this post, if you have any question please comment or send me an e-mail to

Bye, Dami

Nessun commento:

Posta un commento