Qt 4.5 with Visual Studio 2008 (VC++ Express)
Qt is a cross platform GUI toolkit from Nokia. Its SDK is available under an LPGL license, it means we can use it free of charge to develop proprietary, commercial, closed-source software (thanks to Nokia). However, the current LPGL release leaves some gaps in using Qt from within Visual Studio 2008. This is somewhat understandable given that Visual Studio integration was a commercial-only offering and Nokia has Qt Creator (and not Visual Studio). My problem with Qt Creator is it uses MingGW (gcc) compiler which is nowhere near as good as VC++ 2008. Also for Visual Studio background like me, who is not familiar with Qt creator, learning Qt Creator will take time. Thanks to Wiria and AK who brought Qt to my table for a review.
Qt GUI Toolkit is very useful to develop portable application (single source codes) for *NIX, MAC and Windows (including Windows 98 but not being tested for Windows 7). In this post, I will show you how to start using Qt SDK only with Visual C++ 2008, you can use FREE Visual C++ 2008 express too.
Build VC++ Version of Qt
- Download and install qt-sdk-win-opensource-2009.01.1.
- Install the SDK to default directory, in my case C:\qt\2009.01. I didn;t install MingGW and Qt Creator as I don’t need.
- Once QT and VisualStudio 2008 both are installed and ready, open the VisualStudio 2008 Command Prompt.
- Change directory to the Qt SDK installation folder in the Command Prompt. Usually it would be of the form "C:\Qt\2009.01\qt"
- Run Configure.exe to target platform win32-msvc2008. You can simply run by typing configure or using other options. For example:
C:\Qt\2009.01\configure -no-sql-sqlite -no-qt3support -no-opengl -platform win32-msvc2008
-no-libtiff -no-dbus -no-phonon -no-phonon-backend -no-webkit
- Build Qt for use with Visual Studio 2008 by typing nmake
- Configure and nmake will take time, be patient enough. In my case, I started to build 19.17 PM and completed on 23.47 (4:30 hours)!
- Once completed, Qt SDK is ready for Visual Studio 2008.
Build and Run the Qt SDK Samples
Once your Qt SDK is ready to be used you can see samples directory in your Qt SDK installation (usually, C:\Qt\2009.01\qt\examples) and then open the examples.sln file from your Visual Studio 2008. If double-clicking .sln file does not work, open it manually from your Visual Studio. There are a lot of samples from Qt SDK.
If you build and debug – calculator project of instance – you will notification that the application because QtGuid4.dll was not found.
To let Visual Studio knows the include and library files of Qt, add their paths to the:
Visual Studio Tools|Options|Projects and Solutions|VC++ Directories
section. Typically you would want to add C:\Qt\2009.01\qt\include to the Include, C:\Qt\2009.01\qt\lib to the libraries and C:\Qt\2009.01\qt\bin to the Executables sections. Also you can add C:\Qt\2009.01\qt\bin to the Path System variable so that the Qt dlls get probed correctly when loaded from your application.
A lot of Qt samples inside the SDK. Try to build and run those sample applications to see how powerful Qt as GUI Toolkit.
Using Qt’s Visual Studio 2008 Plug-in
You can try Visual Studio add-in RC version (this will be a commercial product) to get integrated Qt templates and visual IDE features in Visual Studio 2008. I will not cover in this post, but this tools is promising. I will show you in my other Qt-VC++ post.
Hope this helps!
Ciao – RAM