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. Cannot open include file: 'QApplication' after including core, gui, & widgets in pro file
Forum Updated to NodeBB v4.3 + New Features

Cannot open include file: 'QApplication' after including core, gui, & widgets in pro file

Scheduled Pinned Locked Moved Unsolved General and Desktop
7 Posts 3 Posters 1.3k Views 1 Watching
  • 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.
  • bockscaracerB Offline
    bockscaracerB Offline
    bockscaracer
    wrote on last edited by
    #1

    Hello folks,

    I'm reverse engineering an example Qt widgets application from scratch. I'm using the Console application in QtCreator as a template so I have minimal boiler plate code to work with.

    I have written a widgets application but I am getting the dreaded:

    Cannot open include file: 'QApplication': No such file or directory
    

    Error and for the life of me, I cannot figure out what is wrong. The .Pro file should tell the compiler what libraries it needs, right? I've added:

    QT       += core gui widgets 
    

    To my .pro file and I am still getting this error. My widgets source application does not get this error. At this point, the code between the two applications are virtually identical, but the application I wrote from the Console template refuses to compile. Its as if the qmake isn't even running when I hit the compile button.

    What on earth am I doing wrong here?

    1 Reply Last reply
    0
    • bockscaracerB Offline
      bockscaracerB Offline
      bockscaracer
      wrote on last edited by
      #2

      I seem to have located the problem - the .pro file isn't being used or parsed at all. I'm not sure how the initial console application was working in the first place.

      Is something fundamentally broken with the Console template application in QtCreator? I'm not even sure how to fix this.

      1 Reply Last reply
      0
      • bockscaracerB Offline
        bockscaracerB Offline
        bockscaracer
        wrote on last edited by
        #3

        I went ahead and reproduced this apparent bug with a standard Console template. My .pro file looks like this:

        QT += widgets
        
        SOURCES += \
                main.cpp
        

        My main.cpp file looks like this:

        #include <QApplication>
        
        int main(int argc, char *argv[])
        {
            QApplication app(argc, argv);
        
            return app.exec();
        }
        

        Even though I am using widgets in my .pro file, I am still getting the error.

        1 Reply Last reply
        0
        • mrjjM Offline
          mrjjM Offline
          mrjj
          Lifetime Qt Champion
          wrote on last edited by
          #4

          Hi
          Do you use the plain c++ console template or
          the qt console template ?

          1 Reply Last reply
          0
          • mranger90M Offline
            mranger90M Offline
            mranger90
            wrote on last edited by
            #5

            Did you re-run qmake ?
            Any change to a .pro file should be accompanied by a clean, run qmake, rebuild.

            bockscaracerB 1 Reply Last reply
            2
            • mranger90M mranger90

              Did you re-run qmake ?
              Any change to a .pro file should be accompanied by a clean, run qmake, rebuild.

              bockscaracerB Offline
              bockscaracerB Offline
              bockscaracer
              wrote on last edited by
              #6

              @mrjj I'm using the Qt Console Application from the QtCreator new project wizard.

              @mranger90 qmake is run when the project is build, no? I've tried a clean re-build and it doesn't seem to matter - the .pro file is simply not being evaluated.

              It is worth pointing out that I tried this code again using the Qt Widgets Application template from the QtCreator wizard and it worked out of the box. Something is up with the Qt Console Application template.

              I'm aware that by definition, the Qt Console Application is not designed to do anything GUI related, however this behavior is more than a little odd.

              1 Reply Last reply
              0
              • mranger90M Offline
                mranger90M Offline
                mranger90
                wrote on last edited by
                #7

                Actually, no. QMake is not necessarily run as part of build or rebuild or rebuild-all.
                You should specifically hit the "build | Run qmake" menu item in QtCreator.
                To verify, check the timestamps on Makefile.Debug and Makefile.Release in the build folders.

                1 Reply Last reply
                2

                • Login

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