我已经安装Qt5.1.1
并创建了一个新的Gui应用程序.mainwindow.h中的代码显示:
#if QT_VERSION >= 0x050000 #include#else #include #endif
我觉得很好.但是当我运行它时,我有这个:
error: C1083: Cannot open include file: 'QtGui/QMainWindow': No such file or directory
我知道什么时候更换
#if QT_VERSION >= 0x050000 #include#else #include #endif
至
#include
有用.
我只是想知道为什么默认代码是错误的以及如何使defauly代码正确.
你可能有另一种选择.
您也可以添加widgets
您的.pro
文件
greaterThan(QT_MAJOR_VERSION, 4): QT += widgets
通过在.pro
文件中添加此行,现在您无需担心Qt版本并包含类似<QtGui/QMainWindow>
或的文件<QtWidgets/QMainWindow>
希望它对你有用.