lunedì 2 novembre 2009

Playing with QT part one: configure your environment

I've been using WxWidgets at work for some time and I wanted to try something different for my framework, so I decided to give a try to Qt.

I had troubles finding good documentation, so here's a small guide about how to configure Qt with MSVC in a few simple steps.

First of all I assume you have a copy of MSVC 2005 (not an express versions). The problem with express versions is they don't support plugins, so the integration with express versions might not be optimal.

Are you ready? Let's go.

1- download a copy of Qt from here. Get the SDK, windows version.
2- install the sdk.
3- add the environment variable "QTDIR = installdir\version\qt". In my case I installed Qt in c:\qt and the version is 2009.04 so "QTDIR = c:\qt\2009.04\qt". To add an environment variable, right-click the computer icon on your desktop, select "properties". A window opens, select "Advanced system settings", then select "Environment variables...".
4- copy the following text "configure -no-sql-sqlite -no-qt3support -no-opengl -platform win32-msvc2005 -no-libtiff -no-dbus -no-phonon -no-phonon-backend -no-webkit", open the notepad and past it. Save as "qt-configure.bat" in "installdir\version\qt". You can play with it, but that configuration works for me. I found it somewhere and looks fine.
5- Launch MSVC. Launch "visual studio command prompt" from tools menu. A visual studio command prompt includes MSVC environment variables. The other solution is to manually open a command prompt (start button->execute->cmd.exe) and launch vcvars32.bat in your MSVC install dir (under vc\bin).
6- type "cd installdrive\installdir\version\qt". In my case "cd c:\qt\2009.04\qt".
7- execute our .bat file by writing "qt-configure" or "qt-configure.bat". Wait until Qt generates all makefiles for MSVC.
8- Launch the compilation with nmake. Type "nmake".
9- Wait until the compilation is completed. It's going to take a lot of time.
10- Close the command prompt and MSVC, download the add-in and install it. At this time the last version is 1.1.1
11- Reboot and start MSVC, go to qt menu->qt options. Add a new version, in my case the path is c:\qt\2009.04\qt.

Now you can use Qt with MSVC. You can create Qt applications and Qt designer plugins easily.

Problems I have encountered so far are:
- After installing the plugin, everytime you execute or compile, MSVC will open the entire solution tree and scroll down until the end of the tree. I hope they'll fix it soon.
- The Qt designer plugin appwizard generates code that needs a small modification to be correctly loaded by the designer. I'll discuss this problem in another post.

I'm using Windows Vista 32-bit and everything works.

3 commenti:

Unknown ha detto...

thanks for the article. it helped. why i could not find this on the official site, is a mystery for me.

Dr.Kappa ha detto...

Thank you for your comment.
I moved my blog to http://www.drkappa.net, soon I will post another entry about QT there: how to create a D3D9 QT control.

Anonimo ha detto...

The information here is great. I will invite my friends here.

Thanks