- API Help integration with MSDN (so F1 context sensitive help works)
- Wizards for Qt projects and skeleton apps
- Qt Designer integration for forms and layout (although this runs as a separate app)
- Automated build process (so it runs the Qt pre-processors then compiles and links the app)
Partner this with Whole Tomato Visual Assist X and you have a pretty nice Qt dev environment.
But before you can actually use Visual Studio you need to compile Qt from source so that you get the libs and DLLs that are compatible with VS. The best way to do this is to download the source Framework (not the prebuilt SDK). I think the only difference is that the framework does not contain Qt Creator.
These steps assume you already have Visual Studio 2008 installed (any version except Express, which doesn't support add-ins), and that Qt is not already installed.
- Download and run qt-win-opensource-4.5.1-mingw.exe (the version number may have changed).
- Choose a destination folder, I chose D:\Qt\4.5.1
- Select the checkbox to download and install MinGW - it is needed for the build process.
- The actual archive unpacking can take quite a while, up to 20 mins or so.
- Add Qt to your system PATH - this means the bin folder, so D:\Qt\4.5.1\bin in my case.
- Add the system environment variable QTDIR=D:\Qt\4.5.1 (substitute your path)
- Reboot your computer for the changes to take effect.
- Run the Visual Studio 2008 Command Prompt (or open an ordinary cmd.exe and run vsvars32.bat from Microsoft Visual Studio 9.0\Common7\Tools folder). This will set the environment variables for the Microsoft compiler tools.
- cd to D:\Qt\4.5.1 (not the bin folder).
- Run the command: configure -platform win32-msvc2008
- Answer O for Opensource, and agree to the license.
- It will make a new qmake.exe, then build pro files for each library and app.
- Run nmake. This can take upwards of 5 hours on a P4 3GHz machine to give you some idea. Also, it will require around 10GB of temporary scratch space to build.
- Wait for hours for the compile to finish...it will build debug and release versions of the libraries and DLLs in the \lib folder, and also all the tools and examples.
- You can delete the *.obj and *.pdb files to claim back around 9GB of disk space. The easiest way to do this is to open a Command Prompt and cd to the Qt folder. Then enter del /s /q *.obj *.pdb
- That's it! If you're a completist you can now uninstall MinGW and also delete mingwm10.dll from the Qt \bin folder, as they are not needed. Confirm everything worked by running qtdemo.exe from \bin.
- Start Visual Studio 2008.
- Click Help -> Contents. This will start MSDN and perform an update of the help files to merge the Qt documentation. This can take quite a while. As in a big cup of coffee.
- In VS select Qt -> Qt Options. Click Add and browse to the installation folder (eg D:\Qt\4.5.1). Enter a version name, eg Qt-4.5.1. Click Ok.
The screenshot above shows a Qt app being developed in VS. Notice the Qt menu and the test2.ui form file in Solution Explorer. Double-clicking the .ui file will open Qt Designer as an external app. Here you can create your GUI, then just save, head back to VS and compile. Job's a good 'un!
i have a problem when i type the nmake command it says it needs a src/winmake && nmake -f makefile and some other stuff...what to do???:S please help thanks
ReplyDeleteCan you give me more detail? What OS are you using and what version of Visual Studio? Did you run vsvars32.bat to set the VS env variables?
ReplyDeleteHi Martin, that post was exactly what I was looking for; you've made my day! Thanks.
ReplyDeleteJust a note : the nmake needed about 5h on my computer (pentium 4 3GHz with 2Gb of RAM) to complete (the precision may help others) and more importantly it needed about 10Gb of disk space (loads of temp files for the compilation) that nearly crashed my system :)
Good point I'll update the info. Glad it helped you out!
ReplyDeleteVery good post. Thanks.
ReplyDeleteHave you tried compiling Qt with VS2010beta1?
ReplyDeleteWith how many files have you ended after compilation? I have 41314 compared to 26484 after installing mingw version. Don't we need some cleanup after building?
ReplyDeleteYes you can safely delete all the *.obj and *.pdb files which will save you about 9GB. I didn't bother deleting them because the space wasn't an issue for me.
ReplyDeletei have installed qt 2010.04
ReplyDeletei get stuck in step 10 when trying to run command: "configure -platform win32-msvc2008"
"configure" is not recognized as a command