14

I've got an existing Visual Studio C++ project. It creates a main window using GLUT and also uses glut for a right-click context menu.

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

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

I have used Qt some years ago to do something similar and it was not so difficult to add it to my project.

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

thanks!

5
  • If you're in Visual Studio, you should probably just use WPF. Oct 26, 2010 at 22:55
  • WPF is .Net no? It's a c++ project i'm working on
    – Mat
    Oct 26, 2010 at 23:00
  • Oh, you just say Visual Studio, so I assume it's a .NET project. Oct 26, 2010 at 23:53
  • I just want a headache-free way to add a very simple graphical userinput to a working c++ application
    – Mat
    Oct 27, 2010 at 0:00
  • The problem is that you don't know how to build your widget without QtCreator ?
    – Andrew
    Oct 27, 2010 at 7:27

4 Answers 4

12

Thank to Arno Duvenhage and Tom for their answers. Here are steps who worked for me in Qt 5.2.1 and Visual Studio 2012 and 2015:

  1. Install QT Add In (for visual studio 2015 is in still in beta, but works fully for me).

  2. Right click the project, select "Unload project".

  3. Add add the <keyword>Qt4VSv1.0</keyword> entry into the <PropertyGroup Label="Globals"> tag.

  4. Select load project.

  5. Select "Convert project to Qt Add-in project" in "Qt 5" menu.

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

  7. In your project properties Linker\Additional Library Directories\ might need to add $(QTDIR)\lib

  8. In your project properties C++\Additional Include Directories\ might need to add $(QTDIR)\include

  9. 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 your generated files folder.

  10. Set your project as startup project.

5

edit your project using an xml editor
i usually unload the project, right click on it and select edit

add the qt version you wish to use (for me it's):

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 fiddle with "convert project to QMake generated project" and it should work

2
  • 1
    the globals didn't work for me. But adding the keyword and setting these configs on property pages did. Apr 18, 2016 at 14:54
  • This worked for me with Qt 5.9.9 and Visual studio 2019. "convert project to QMake generated project" is located in the file menu under Extensions->QT VS Tools or by Right-clicking on the project -> Qt Apr 5, 2020 at 20:46
4

This works for me:

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

Hope it helps.

1
  • 1
    To be more precise add the <keyword>Qt4VSv1.0</keyword> entry into the <PropertyGroup Label="Globals"> tag. Then select Nov 18, 2016 at 8:28
-4

There is an ability of qmake to generate .vcproj from a .pro file. So you should read qmake documentation to create a right .pro file.

Not the answer you're looking for? Browse other questions tagged or ask your own question.