我在make qt开发的mind map的时候出现了下面的错误:

/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang++ -c -pipe -stdlib=libc++ -O2 -std=gnu++11 -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.13.sdk -mmacosx-version-min=10.7 -Wall -W -fPIC -DQT_NO_DEBUG -DQT_SVG_LIB -DQT_WIDGETS_LIB -DQT_GUI_LIB -DQT_XML_LIB -DQT_CORE_LIB -I. -I/anaconda/include/qt -I/anaconda/include/qt/QtSvg -I/anaconda/include/qt/QtWidgets -I/anaconda/include/qt/QtGui -I/anaconda/include/qt/QtXml -I/anaconda/include/qt/QtCore -I. -I/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.13.sdk/System/Library/Frameworks/OpenGL.framework/Headers -I/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.13.sdk/System/Library/Frameworks/AGL.framework/Headers -I. -I/anaconda/mkspecs/macx-clang -o main.o src/main.cpp
src/main.cpp:16:18: error: variable has incomplete type 'QApplication'
QApplication a(argc, argv);
^
/anaconda/include/qt/QtCore/qobject.h:453:18: note: forward declaration of
'QApplication'
friend class QApplication;
^
src/main.cpp:45:13: error: use of undeclared identifier 'QMessageBox'
QMessageBox::critical(0,
^
src/main.cpp:50:9: error: incomplete type 'QApplication' named in nested name
specifier
QApplication::setQuitOnLastWindowClosed(false);
^~~~~~~~~~~~~~
/anaconda/include/qt/QtCore/qobject.h:453:18: note: forward declaration of
'QApplication'
friend class QApplication;
^
3 errors generated.
make: *** [main.o] Error 1

只需要在出错的地方加上头文件:

#include <QApplication>
#include <QMessageBox>

就可以了。

参考文献

[1].View Full Version : [SOLVED] qtcreator help. ​​https://ubuntuforums.org/archive/index.php/t-2271011.html​