简体   繁体   English

Visual Studio / Qt - 无法打开源文件“QApplication”

[英]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 .我有VS 2017qt-opensource-windows-x86-msvc2015_64-5.8.0qt-vsaddin-msvc2017-2.6.0-rev.07

https://api-2d3d-cad.com/c-qt/ to setup. https://api-2d3d-cad.com/c-qt/进行设置。

Qt VS Tools widget is present, can make Qt Console Application. Qt VS 工具小部件存在,可以制作 Qt 控制台应用程序。

But:但:

#include <QMainWindow>
#include <QLabel>

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

https://stackoverflow.com/a/16682269/10226040 - tried, not working. https://stackoverflow.com/a/16682269/10226040 - 尝试过,不工作。

Thx.谢谢。

To use Qt libs in Visual studio do next steps!要在 Visual Studio 中使用 Qt 库,请执行以下步骤! This answer is based on Visual studio 2017 , on other versions, differences are only on menus or settings interfaces!此答案基于Visual studio 2017 ,在其他版本上,差异仅在菜单或设置界面上!

  1. Install Qt Vs Tools , check its version compatibility with Visual studio安装Qt Vs Tools ,检查其与 Visual Studio 的版本兼容性

  2. Go Qt VS Tools -> Qt Options menu Go Qt VS 工具 -> Qt 选项菜单在此处输入图像描述

  3. In Qt Versions tab, add installed Qt libs with its path and name, and set default Qt/Win versionQt Versions选项卡中,添加已安装的 Qt 库及其路径和名称,并设置默认 Qt/Win 版本

  4. Check Qt Default Settings tab, it seems as below检查Qt Default Settings选项卡,如下所示在此处输入图像描述

  5. On Solution Explorer view, open project properties, go Qt Project Settings and on Qt Modules tab set required modules such as Core .Solution Explorer视图中,打开项目属性,go Qt Project SettingsQt Modules选项卡上设置所需的模块,例如Core 在此处输入图像描述 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.您可以在选项卡中查看其他设置Qt Meta-Object Compiler以更改moc文件生成设置, Qt User Interface Compiler以更改formui编译设置。

  6. If you have any form file, ie *.ui file, you can get its properties and check followings are set properly by default!如果您有任何表单文件,即*.ui文件,您可以获取其属性并检查以下是否默认设置正确! or modify them as you need!或根据需要修改它们!

在此处输入图像描述 在此处输入图像描述

  1. Go C/C++ Tab, General , check Additional Include Directories stared items must be exist! Go C/C++ 选项卡, General ,检查Additional Include Directories ,必须存在! 在此处输入图像描述

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM