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.  
01

- 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.

03 09

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.

12

If you build and debug – calculator project of instance – you will notification that the application because QtGuid4.dll was not found.

10  11

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.

13

A lot of Qt samples inside the SDK. Try to build and run those sample applications to see how powerful Qt as GUI Toolkit.

14

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.

04 

Hope this helps!

 

Ciao – RAM

Share this post: | | | |
Published Thursday, April 2, 2009 1:31 AM by Risman Adnan Mattotorang

Comments

# re: Qt 4.5 with Visual Studio 2008 (VC++ Express)

Bookmarked :)

Thursday, April 2, 2009 7:09 AM by ridi

# Working with Qt Visual Studio 2008 Add-In

After built and configured your Qt 4.5 SDK , you can download and install qt-vs-addin-1.0.0- rc1 .exe

Thursday, April 2, 2009 7:03 PM by Risman Adnan

# re: Qt 4.5 with Visual Studio 2008 (VC++ Express)

with qt-vs-addin you don't have to add the include/lib-files in visual studio, do you?

An another tutorial tells to set the environment variable QTDIR="" for this addin...

Friday, April 3, 2009 12:19 AM by hiccup

# re: Qt 4.5 with Visual Studio 2008 (VC++ Express)

Hi, I just posted how to use the Qt Add-in for VS 2008. Easy, go to menu Qt after installation, choose Options and then set the location of your Qt directory.

Friday, April 3, 2009 8:02 AM by Risman Adnan Mattotorang

# re: Qt 4.5 with Visual Studio 2008 (VC++ Express)

Bookmarked :)

Thursday, April 02, 2009 7:09 AM by ridi

-------------------------------------------

ditto!

Saturday, April 4, 2009 6:20 PM by osm

# Windows 7 Release Candidate gets new features

I still can't believe their so ontime for the RC release, Gone are the Vista days i guess.

Monday, April 27, 2009 10:30 PM by Windows 7 Release Candidate gets new features