Question

I have a Qt project(.pro) which essentially uses Qt libraries and OpenGL and i need to integrate this project with an existing VS2008 project(.vcproj) which uses a 3rd party API on another system.

The VS project interfaces with a hardware(along with many other functions) through a serial port and i intend to use its event handler to trigger the actions in Qt( since a serial port cannot be opened by two programs simultaneously? )

I use Qt v4.8.1 with mingw complier. i did come across a VS plugin for Qt. but i'm not sure as to how the above task of integration can be done.

I'll be thankful if you can kindly shed some light on this.

Was it helpful?

Solution

My advice would be to completely integrate the source of the Qt project into the VS project. It's possible to compile Qt code in visual studio. Of course, this requires to configure your VS project to make it "qt-ready". In detail:

  1. Integrate the source code of the qt project into the VS solution. This means, the header files, the cpp files and the ui files you might have.
  2. You still need the Qt libraries on your system in order to compile QT source with visual studio. I recommend to install "qt-win-opensource-4.8.1-vs2008.exe". These are the special Qt 4.8.1 libaries for VS 2008 (pre-compiled). Can be found here: http://download.qt-project.org/archive/qt/4.8/4.8.1/
  3. You have to tell visual studio how to "pre-compile" the Qt source with the installed Qt binaries. This can be down in two ways:

I. You can configure the project properties of your VS project. Unfortunatelly I have never used this way, so I don't know exactly how to do this.

II. You can use CMake to setup your VS project. CMake allows the simple integration of Qt libaries and compilers. Using CMake means to write a CMakeLists.txt, which generates the VS project for you. Here you can find a sample, explaining how to write a CMakeLists.txt with Qt support: http://www.cmake.org/Wiki/CMake/Tutorials/Qt

Also, the Qt plugin for visual studio you mentioned is optional. You do not need it to build a Qt project with visual studio, but it makes some issues easier, e.g. debugging or calling the Qt designer from visual studio.

Hope this helps, Michael

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top