qt src/main.cpp:16:18: error: variable has incomplete type 'QApplication'

我在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

  • 4
    点赞
  • 4
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

农民小飞侠

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值