Qt is a cross-platform application and UI framework. Using Qt, you can write web-enabled applications once and deploy them across desktop, mobile and embedded operating systems without rewriting the source code.
Recently I installed Qt 4.5.2 on my Windows 7 PC and had some minor installation and post-installation issues which I shall discuss here.
Download Qt SDK: Follow this link to download
Qt is available for download as a free 30-day commercial evaluation, or under the LGPL open source license. Choose whichever license you want. However, every time you build projects using commercial edition Qt will display a license popup.
Install Qt to whichever directory you want. Like i installed it at C:\Qt\2009.03\ . This path will be needed later.
Write a simple Qt-c++ program like the one given below just so that we can use it to test if the installation is properly done and the environment variables are properly set. Just write this piece of code in notepad and save it as HelloQt.cpp in a directory HelloQt. Remember the path since it will be used later.
int main(int argc, char *argv)
QApplication app(argc, argv);
QLabel *label = new QLabel(” Hello Qt!”,0);
Setting Environment variables.
Append the following variable value to Path : C:\Qt\2009.03\bin; C:\Qt\2009.03\qt\bin
Note that the above Path depends on the directory where Qt was installed previously, like mine was C:\Qt\2009.03\.
Open Qt command prompt which is installed along with Qt and has a shortcut in Start-menu.
Change directory to where you have saved HelloQt.cpp in your system.
Type the following commands …
The first command will generate a .pro file (HelloQt.pro)
The next command will generate a MakeFile for your project
Finally nmake shall create a .exe file of your project and the .exe shall be saved inside either the debug or the release folder by the name HelloQt.exe
Problem with using nmake command
If windows shows some error like “nmake is not a recognised internal or external command”, this means nmake is not installed on your system. To install, you need to downloading, extract, and place two files into your C:\WINDOWS\system32 or C:\WINDOWS\ folder.
Follow the steps below to install nmake on your PC
- Download nmake : Use this link or Google nmake15.exe if this links is broken –http://download.microsoft.com/download/vc15/Patch/1.52/W95/EN-US/Nmake15.exe
- Extract nmake: Run the Nmake15.exe file which will extract two files to the directory where it is located. These files will be nmake.exe and NMAKE.ERR.
- Now move those two extracted files to C:\WINDOWS\system32.
This should install nmake on your system.
If you follow the above steps correctly, you are ready to use Qt to create GUI applications on your Windows PC.