我正在尝试在VS上构建一个C ++项目。该项目是在Linux机器上使用NetBeans开发的,现在我在Windows上使用Visual Studio 2017。
它没有使用Qt Creatos开发,因此手动添加了库,例如:
#include <QtCore>
#include <QCoreApplication>
#include <QObject>
#include <QStringList>
#include <QMap>
...
这是我到目前为止所做的:
然而,当我尝试#include <QtCore>
时,似乎VS期待更多:
https://imgur.com/a/ruSbi
但它没有编译。
Severity Code Description Project File Line Suppression State
Error (active) E0020 identifier "QEvent" is undefined c:\Qt\Qt5.9.2\5.9.2\msvc2017_64\include\QtCore\qabstractanimation.h 121
Error (active) E0020 identifier "QEvent" is undefined c:\Qt\Qt5.9.2\5.9.2\msvc2017_64\include\QtCore\qabstractstate.h 73
Error (active) E0020 identifier "QEvent" is undefined c:\Qt\Qt5.9.2\5.9.2\msvc2017_64\include\QtCore\qabstractstate.h 74
Error (active) E0020 identifier "QEvent" is undefined c:\Qt\Qt5.9.2\5.9.2\msvc2017_64\include\QtCore\qabstractstate.h 76
Error (active) E1455 member function declared with 'override' does not override a base class member c:\Qt\Qt5.9.2\5.9.2\msvc2017_64\include\QtCore\qabstracttransition.h 105
Error (active) E1455 member function declared with 'override' does not override a base class member c:\Qt\Qt5.9.2\5.9.2\msvc2017_64\include\QtCore\qanimationgroup.h 70
Error (active) E1455 member function declared with 'override' does not override a base class member c:\Qt\Qt5.9.2\5.9.2\msvc2017_64\include\QtCore\qcoreapplication.h 190
Error (active) E0020 identifier "qint8" is undefined c:\Qt\Qt5.9.2\5.9.2\msvc2017_64\include\QtCore\qdatastream.h 147
Error (active) E0020 identifier "qint8" is undefined c:\Qt\Qt5.9.2\5.9.2\msvc2017_64\include\QtCore\qdatastream.h 163
Error (active) E0260 explicit type is missing ('int' assumed) c:\Qt\Qt5.9.2\5.9.2\msvc2017_64\include\QtCore\qendian.h 236
Error (active) E0801 "qint8" is not a class or function template name in the current scope c:\Qt\Qt5.9.2\5.9.2\msvc2017_64\include\QtCore\qendian.h 236
Error (active) E0065 expected a ';' c:\Qt\Qt5.9.2\5.9.2\msvc2017_64\include\QtCore\qendian.h 236
Error (active) E0020 identifier "qint8" is undefined c:\Qt\Qt5.9.2\5.9.2\msvc2017_64\include\QtCore\qendian.h 236
Error (active) E0020 identifier "QEvent" is undefined c:\Qt\Qt5.9.2\5.9.2\msvc2017_64\include\QtCore\qeventloop.h 79
Error (active) E1455 member function declared with 'override' does not override a base class member
...
所以,我想我错过了一些东西。我是VS的新手,所以我很感激任何帮助。
谢谢
答案 0 :(得分:2)
QtCore
既是目录又是包含文件:
Directory: <Qt_Install_Path>/include/QtCore
File: <Qt_Install_Path>/include/QtCore/QtCore
此外,您需要在包含moc
宏的每个标头上运行Qt Q_OBJECT
。 moc
将生成额外的C ++文件,您需要编译它们。使用qmake
或cmake
等工具时相当简单。对于VS,您可能会使用Qt Visual Studio Add-in。