Chainsaw
Chainsaw

Reputation: 311

Visual Studio / Qt - Cannot open source file "QApplication"

I have VS 2017, qt-opensource-windows-x86-msvc2015_64-5.8.0, qt-vsaddin-msvc2017-2.6.0-rev.07.

https://api-2d3d-cad.com/c-qt/ to setup.

Qt VS Tools widget is present, can make Qt Console Application.

But:

#include <QMainWindow>
#include <QLabel>

Cannot open source file "QApplication"
Cannot open source file "QLabel"

https://stackoverflow.com/a/16682269/10226040 - tried, not working.

Thx.

Upvotes: 1

Views: 6374

Answers (1)

Ali Razmkhah
Ali Razmkhah

Reputation: 270

To use Qt libs in Visual studio do next steps! This answer is based on Visual studio 2017! on other versions, differences are only on menus or settings interfaces!

  1. Install Qt Vs Tools, check its version compatibility with Visual studio

  2. Go Qt VS Tools -> Qt Options menu enter image description here

  3. In Qt Versions tab, add installed Qt libs with its path and name, and set default Qt/Win version

  4. Check Qt Default Settings tab, it seems as below enter image description here

  5. On Solution Explorer view, open project properties, go Qt Project Settings and on Qt Modules tab set required modules such as Core. enter image description here You can see other settings in tabs Qt Meta-Object Compiler to change moc file generation settings, Qt User Interface Compiler to change form and ui compilation settings.

  6. If you have any form file, i.e. *.ui file, you can get its properties and check followings are set properly by default! or modify them as you need!

enter image description here enter image description here

  1. Go C/C++ Tab, General, check Additional Include Directories stared items must be exist! enter image description here

Upvotes: 2

Related Questions