How to convert a regular win32 (VC++ vcproj) project to a Qt project?

Morten Fjeldstad picture Morten Fjeldstad · Jan 18, 2010 · Viewed 20.1k times · Source

How can I convert existing vcproj files to project files that the QT add-in to Visual Studio recognizes and treats as valid Qt projects?

Should I just bite the bullet and create new projects to replace the old ones, and then add existing code?

I am using QT 4.6 and VS 2008 with Qt Add-in 1.1.2. Original vcproj files have NOT been generated with QMake.

Answer

Jade picture Jade · Jul 18, 2012

Using Visual Studio 2010+ it is now possible to convert a project to a Qt Addin project, using the "Convert project to Qt Add-in project" feature of the Qt Addin.

The following steps are from the work around in bug QTVSADDINBUG-27. This was tested with Visual Studio 2010, but should work similarly with new versions:

  1. Right click on your project in "Solution Explorer", click on "Unload Project"
  2. Right click on your project in "Solution Explorer", click on "Edit .vcxproj"
  3. Add line <Keyword>Qt4VSv1.0</Keyword> between the tags <PropertyGroup Label="Globals"> and </PropertyGroup>.
  4. Right click on your project in "Solution Explorer", click on "Reload Project"
  5. Right click on your project in "Solution Explorer", click on "Convert project to Qt Add-in project"

If you have header files in your project you are going to have to follow the instructions in this answer to trigger the generation of moc_* files in the "Generated Files" folder.

For editions of Visual Studio older than 2010 see this work around.