小编Sam*_*dav的帖子

QT5 错误:未知类型名称“QCoreApplication”。Qt5 中的第一个程序

我刚刚在 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 行中。

c++ user-interface qt5 qcoreapplication qapplication

3
推荐指数
1
解决办法
4335
查看次数