Sam*_*dav 3 c++ user-interface qt5 qcoreapplication qapplication
我刚刚在 Linux Ubuntu 20.04 LTS 中安装了 QTCreator,单击“文件”->“新建项目”->“应用程序”->“QTConsole 应用程序”。制作了first.pro 文件和main.cpp 文件。
第一个.pro 包含:
QT -= gui declarative
QT += widgets
CONFIG += c++11 console
CONFIG -= app_bundle
DEFINES += QT_DEPRECATED_WARNINGS
SOURCES += \
main.cpp
qnx: target.path = /tmp/$${TARGET}/bin
else: unix:!android: target.path = /opt/$${TARGET}/bin
!isEmpty(target.path): INSTALLS += target
Run Code Online (Sandbox Code Playgroud)
main.cpp 包含:
#include <QCoreApplication>
int main(int argc, char *argv[])
{
QCoreApplication a(argc, argv);
return a.exec();
}
Run Code Online (Sandbox Code Playgroud)
错误出现在 QCoreApplication 行中。
原因是Ubuntu 20.04上安装了新版本的Qtcreator clang-10,但仍然需要clang-8。
安装 clang-8 包:
apt install clang-8
Run Code Online (Sandbox Code Playgroud)