Sameer Yadav
Sameer Yadav

Reputation: 39

QT5 error: Unknown type name 'QCoreApplication'. First program in Qt5

I have just installed QTCreator in Linux Ubuntu 20.04 LTS, I clicked on File->New Project->Application->QTConsole Application. A first.pro file and main.cpp file was made.

The first.pro contains:

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

The main.cpp contains:

 #include <QCoreApplication>

int main(int argc, char *argv[])
{
    QCoreApplication a(argc, argv);
    return a.exec();
}

The error comes in QCoreApplication line.

Upvotes: 3

Views: 4825

Answers (2)

Colin McGovern
Colin McGovern

Reputation: 124

If the error is an open red circle, the code will still build.

If you want to get rid of the open red circles, go into Help->About Plugins and uncheck the Clang code model plugin. Then restart QT creator.

Upvotes: 0

Jorge Luis
Jorge Luis

Reputation: 955

The reason is that new versions of Qtcreator on Ubuntu 20.04 install clang-10, but it still needing clang-8.

Install clang-8 package:

apt install clang-8

Upvotes: 8

Related Questions