Tuesday 6 August 2013

Qt 4 Software Development


Qt 4 is a C++ Application Framework that is mostly deployed in making of Graphical User Interface Software Applications e.g., VLC Media PLayer is a good example of Qt Software. First, I would want you to know how to configure windows environment for Qt Applications. Download latest Qt creator which may also be shipped together with Qt SDK but you should download latest Qt SDK and also MinGW compiler. Follow setup and install simply as you do with other software but after you install you must configure the environment before development.
  •  You will need an Internet connection to install MinGW compiler.
  • Before Qt installation you should have MinGW installed and MinGW\bin folder in your PATH.
  • After installation navigate to Qt\<sdk version> folder and look for "configure.exe" file.
  • Open that file and choose Open Source Edition where prompted to, that is, type "o" on the shell.
  • Accept license by typing 'yes' and wait for it to finish executing.
  • Make sure your Qt\<sdk version>\bin is in your PATH.
  • Note that you should download Qt SDK that supports MinGW compiler.
 A Hello World sample program is shown below.

#include <QApplication.h>
#include <QPushButton.h>

int main( int argc, char **argv )
{
QApplication a( argc, argv );
QPushButton hello( "Hello World!");
hello.show();
return a.exec();
}


Save the source code into a file "main.cpp".
Create a new file using your notepad or any text editor program and enter the following commands in it.

qmake -project
qmake
make
cd debug
qt

save it as batch script file, that is, "<file name>.bat" file should have a .bat extension.
Open your command line program or double click on the batch script to execute when on the command line drag the batch script file and drop it to the command line program and then press Enter to execute file. You should have an execution similar as below.



You should have some files created such as qt project file, Makefile file and other folders debug, release, etc in that folder that main.cpp file resides. The output should be similar to that below.




Note: You can navigate to the debug folder where you'll find an executable which when you open should give you a GUI window.
Download Available:  Click here

1 comment:

  1. I had never heard of Qt4 framework before. This is something new to my ears. Glad I came by this blog post and read this article.

    Regards,
    Prasant Saxena
    Software Development Company

    ReplyDelete