Qt Forum

    • Login
    • Search
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Unsolved

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

    General and Desktop
    3
    4
    9116
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • M
      Muhammad last edited by

      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 +=
      main.cpp
      hello.cpp

      HEADERS +=
      hello.h@

      and here is the .h file

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

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

      MyPushButton::MyPushButton(const QString &text)
      : QPushButton(text)
      {
      setObjectName("mypushbutton");
      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);
      
      helloButton.show();
      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

      I don't have endpoint, I just have Checkpoints.

      1 Reply Last reply Reply Quote 0
      • A
        amccarthy last edited by

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

        1 Reply Last reply Reply Quote 0
        • A
          andre last edited by

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

          1 Reply Last reply Reply Quote 0
          • M
            Muhammad last edited by

            Thank you everybody, It was like amccarthy said.

            I don't have endpoint, I just have Checkpoints.

            1 Reply Last reply Reply Quote 0
            • First post
              Last post