Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. C1083: Cannot open include file: 'QApplication' [SOLVED]

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

Scheduled Pinned Locked Moved General and Desktop
4 Posts 3 Posters 9.7k Views
  • 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 Offline
    M Offline
    Muhammad
    wrote on 25 Mar 2013, 22:27 last edited by
    #1

    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
    0
    • A Offline
      A Offline
      amccarthy
      wrote on 26 Mar 2013, 00:25 last edited by
      #2

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

      1 Reply Last reply
      0
      • A Offline
        A Offline
        andre
        wrote on 26 Mar 2013, 15:34 last edited by
        #3

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

        1 Reply Last reply
        0
        • M Offline
          M Offline
          Muhammad
          wrote on 27 Mar 2013, 11:54 last edited by
          #4

          Thank you everybody, It was like amccarthy said.

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

          1 Reply Last reply
          0

          1/4

          25 Mar 2013, 22:27

          • Login

          • Login or register to search.
          1 out of 4
          • First post
            1/4
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • Users
          • Groups
          • Search
          • Get Qt Extensions
          • Unsolved