0

I understand I can use Qt5 in Visual Studio by using the Visual Studio Add-in for Qt as mentioned in Building Qt5 with Visual Studio 2012 / Visual Studio 2013, and integrating with the IDE.

Is it possible to use Qt5 in Visual Studio without using the Add-in?

Also, I would like to use CMake to generate the Visual Studio Project.

Community
  • 1
  • 1
user3731622
  • 4,844
  • 8
  • 45
  • 84

1 Answers1

1

Yup.

I have it working for a pretty complex subdirs template.

Qmake can generate the visual studio solution file and vcxproj, look here:

http://doc.qt.io/qt-5/qmake-platform-notes.html#creating-visual-studio-project-files

What I do is use the Qmake project as the master project, and generate the VS stuff out of folder as temporaries. This prevents Visual studio from tangling up in your source files as well as in the qmake stuff. And you can also port it to other OSs without any hassle. Using this approach, if you want to add files to your project, don't do it through VS, but add it to the .PRO file and re-run qmake.

The only thing (that I've found) is if you change anything that needs to be MOC'd, then re-run qmake.

If you want CMake exclusively then this is a nice guide

http://www.kdab.com/using-cmake-with-qt-5/.

The qmake way is a little cleaner as you don't get all the extra noise of finding Qt libraries as you need in CMake.

Tom Kulaga
  • 138
  • 7
  • Thanks. I had a problem while trying to do use qt5 in visual studio without the Add-in, and so I wasn't sure if I needed the Add-in. I had a problem b/c I didn't know I had to put the Qt .dll files and platforms/qwubdiws,dll into the directory of my .exe. If you know how I can avoid copying and pasting these files, I would love to know. – user3731622 Sep 02 '15 at 17:41
  • Copy the bin directory path of the Qt installation to your path environment variable. It's of the form C:\Qt\5.x\mingw(msvc)\bin. Be sure to restart Visual Studio after you change the path if its open. If your project has internal dll libraries that can't be found, I usually overcome that by having all the dll and exe files output to a single folder unlike the visual studio default to seperate them. – Tom Kulaga Sep 02 '15 at 22:41