Add Qt to an Existing Visual Studio C ++ Project

I have an existing Visual Studio C ++ project. It creates the main window using GLUT, and also uses bend for the context menu of the context menu.

All I want to do now is open a second window, which is used as a property inspector to display and change some values.

Everyone recommends using Qt to develop a GUI, but all the tutorials that I find discuss either working in a Qt creator, or how to create a Qt project from scratch.

I used Qt a few years ago to do something similar, and it was not so difficult to add it to my project.

Can someone explain or point me to a tutorial explaining how to do this?

thanks!

+4
source share
4 answers

Thanks to Arno Duvenhage and Tom for their answers. Here are the settings that worked for me in Qt 5.2.1 and Visual Studio 2012 and 2015:

  • Install QT Add In (for Visual Studio 2015 it is still in beta testing, but it works completely for me).

  • Right-click on the project, select "Upload Project".

  • Add a Qt4VSv1.0 entry to the tag.

  • Select a download project.

  • Select "Convert project to Qt add-in project" in the "Qt 5" menu.

  • Almost done. Go to the Qt project settings and the Qt option in the Qt menu to set the details.

  • In your project properties Linker \ Additional Library Directories \ you may need to add $ (QTDIR) \ lib

  • In your C ++ project properties \ Aditinal include directories \ may need to add $ (QTDIR) \ include

  • In each of your classes derived from Q_OBJECT, delete the Q_OBJECT macro, save the file, return the Q_OBJECT macro (Ctrl + Z) and save again. It adds the moc files to the generated files folder.

  • Define the project as a startup project.

+3
source

edit your project using xml editor
I usually upload the project, right click on it and select edit

add the qt version you want to use (for me this):

Keyword="Qt4VSv1.0" 

and the following globals

  <Global Name="lupdateOnBuild" Value="0" /> <Global Name="MocDir" Value=".\GeneratedFiles\$(ConfigurationName)" /> <Global Name="MocOptions" Value="" /> <Global Name="QtVersion Win32" Value="QT 4.5.3" /> <Global Name="RccDir" Value=".\GeneratedFiles" /> <Global Name="UicDir" Value=".\GeneratedFiles" /> 

reload the project and try "convert the project to a project generated by QMake" and it should work

+2
source

This works for me:

  • manually change the project version to the qt project in the project file - use <Keyword>Qt4VSv1.0</Keyword>'
  • reload project
  • right click on the project and select "update to a qt-addin project"
  • delete and add the qt source files to the project

Hope this helps.

+2
source

There is the possibility of qmake generating .vcproj from a .pro file. Therefore, you should read the qmake documentation to create the correct .pro file.

0
source

All Articles