Important: Please read the Qt Code of Conduct -

C1083: Cannot open include file: 'QApplication' [SOLVED]

  • I created a very simple project using "Empty Qt project" from Qt Creator.
    Then I added my files to the project.

    Here is the .pro file

    @CONFIG += qt
    SOURCES +=

    HEADERS +=

    and here is the .h file

    @#include <QPushButton>
    class MyPushButton : public QPushButton
    MyPushButton(const QString &text);

    and here is the .cpp file
    @#include <QDebug>
    #include "hello.h"

    MyPushButton::MyPushButton(const QString &text)
    : QPushButton(text)
    qDebug() << "My PushButton has been constructed";

    and here is the main file
    @#include <QApplication>
    #include "hello.h"

    int main(int argc, char **argv)
    QCoreApplication app(argc, argv);

    MyPushButton helloButton("Hello world!");
    helloButton.resize(100, 30);;
    return app.exec(&#41;;


    when I run the project I get the errors
    C1083: Cannot open include file: 'QApplication' No such file or directory
    C1083: Cannot open include file: 'QPushButton' No such file or directory

    I added this line to the .pro file
    @ QT += widgets @

    and rerun qmake and rebuild

    When I run again I get no errors but the I get this
    The program has unexpectedly finished.
    and then nothing happens
    So please HELP

  • You are instantiating a QCoreApplication. For a widget based application you should be using a QApplication.

  • And, for that to work properly, make sure you have this in your .pro file:
    qt *= core gui widgets

  • Thank you everybody, It was like amccarthy said.

Log in to reply