Friday, July 30, 2010

Nokia QT with Visual Studio 2008 and MFC to QT

As the option to download only the Qt source code is a bit obfuscated on the current Nokia website, please follow these directions:

Go to and click the Go LGPL button.
Since you want only source code, look at the Qt: Framework Only column on the right. Click e.g. Download Qt libraries 4.6.3 for Windows (VS 2008, 194 MB) — choose the VS2008 one.

This starts the download for pre-built Qt. But we don’t want that as we will be building Qt ourselves. A page will appear with . Cancel the Save As dialog in your browser to cancel the binaries download you had clicked on, then click on this link, e.g.
Unzip the file into e.g. c:\qt\4.6.3-vc. Please use a path with no embedded spaces, as the Qt build tools have issues with them.
Open Computer Properties | Advanced system settings | Environment Variables:

Edit environment variable to add: QTDIR = c:\qt\4.6.3-vc
Edit the PATH environment variable to add: %QTDIR%\bin
Either close all command prompts and Visual Studio instances, or reboot... the computer so the new command-line takes effect.
Open a Microsoft Visual Studio 2008 Command Prompt, which is a command console with environment variables set for the specified VS. This is easily accomplished using Start | All Programs | Microsoft Visual Studio 2005 (or 2008) | Visual Studio Tools | Visual Studio 2005 (or 2008) Command Prompt.
Cleanup any previous build:
c:\> cd c:\qt\4.6.3-vc
c:\qt\4.6.3-vc> nmake distclean

c:\qt\4.6.3-vc> rm -rf tmp* // <– recursively remove all tmp\ folders and files
I use GNU Tools or even better Cygwin. Cygwin is very useful because you can also build other open source unix source code library including complicated ffmpeg that you may want to link to your QT project. You can download the gnuwin32 package maintenance utility on the project portal. Cygwin can be downloaded here

3. Run Configure to target platform vc2008:

c:\qt\4.6.3-vc> configure -platform win32-msvc2008

Run Configure with no parameters to see a help screen. Configure generates nmake compatible makefiles to build all the Qt DLL’s, tools, and demos.

4. Run nmake to build.

c:\qt\4.6.3-vc> nmake

It will take awhile, but this grinds through building the specified Qt DLL’s, tools, and demos with Visual Studio.

The Qt Visual Studio Add-in is indispensible for developing Qt apps in Visual Studio. The Add-in has replaced the previous Qt Visual Studio Integration, which was only available to Commercial customers. Now the Add-in is used by both LPGL and Commercial licensees, and the Integration has been deprecated. While the Add-in does not allow integrated .ui editing (it instead launches Qt Designer to edit .ui files), it is fully supported and maintained by Nokia, whereas the Integration hadn’t been modified since the 4.3/4.4 timeframe.

Because Visual Studio Express does not allow add-ins, using these free versions of Visual Studio is not recommended for Qt development. You need at least Visual Studio Standard (Pro, Team System, etc. of course will also work).

1. Download and install the Qt Visual Studio Add-in to install the Qt plug-in into Visual Studio (both 2005 and 2008 are supported by the add-in).

2. Start Visual Studio.

3. Select menu Qt | Configure Qt Versions. Add c:\qt\4.6.3-vc.

4. Now Qt is fully functional, and you can use VS2008 to build Qt apps.

1. See Qt menu item. Launch Qt Designer (the Resource editor) and Qt Linguist (the localization tool).

2. Create new Qt projects. File | New project, select Qt4 project.

3. Read Qt Help. Available from Help menu (Qt help is merged in with Visual Studio Help and viewed in Document Explorer.) Or, manually launch


4. The Whole Tomato Visual Assist X plug-in is highly recommended to develop Qt within Visual Studio


How to generate a vc proj from a .pro QT file

there are two ways to do it.

1. On the command line with "qmake -tp vcapp -r"

Ensure that the QMAKESPEC environment variable is set to the appropriate value.
If you use Visual Studio 2008, then win32-msvc2008 is the correct value.

To set your environment variables in Windows, please see
Note that you may have to re-open a command window before your settings are changed.
To check that your PATH is set correctly:
C:\> qmake -v
QMake version: 2.01a
Using Qt version 4.6.3 in C:\Qt\4.6.3\lib
To see if QMAKESPEC is set correctly:
C:\> echo %QMAKESPEC%
%QMAKESPEC% // not set
win32-msvc2008 // set

2. With the Qt Visual Studio integration via the menu "Qt->Open From
.pro File" and save your project to also save the visual studio solution .sln file

==================== MFC AND QT

This walkthrough covers the migration of an MFC based program, generated by Microsoft Visual Studio's MFC Application Wizard, to the Qt toolkit using the Windows Migration Framework.

and Nokia as a very nice landing page for this

No comments: