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. [Solved] New Qt Gui project from QtCreator does not compile
Forum Updated to NodeBB v4.3 + New Features

[Solved] New Qt Gui project from QtCreator does not compile

Scheduled Pinned Locked Moved General and Desktop
12 Posts 2 Posters 15.2k 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.
  • sierdzioS Offline
    sierdzioS Offline
    sierdzio
    Moderators
    wrote on last edited by
    #2

    Tell us what error messages are you getting, check if your project is properly configured, whether Kits are set up, etc. Can you compile Qt4 apps without problems, or is this not working, too?

    (Z(:^

    1 Reply Last reply
    0
    • B Offline
      B Offline
      blindflyer
      wrote on last edited by
      #3

      Thanks for looking into this, I'll rephrase.
      It's real easy to reproduce this problem.

      • Start QtCreator (/opt/Qt5.0.1/Tools/QtCreator/bin/qtcreator)
      • File / New File or Project
      • Select Applications / Qt Gui Appication and do Choose...
      • Choose any name
      • I get a list of kits, I choose "Desktop Qt 5.0.1 GCC 64bit" and Debug + Release options
      • Then hit Next until I get Finish, accepting defaults
      • Now QtCreator has created an empty Qt Gui app
      • Build the app with Build All
      • Error: QMainWindow: No such file or directory

      Kind regards,
      Wino.

      1 Reply Last reply
      0
      • B Offline
        B Offline
        blindflyer
        wrote on last edited by
        #4

        Oh, and yes Qt 4.8.1 works fine.

        1 Reply Last reply
        0
        • sierdzioS Offline
          sierdzioS Offline
          sierdzio
          Moderators
          wrote on last edited by
          #5

          Is QMainWindow header included with <QtGui/QMainWindow>, by any chance? If so, it is wrong (in Qt5), and of course a bug. Use just <QMainWindow> or <QtWidgets/QMainWindow> instead.

          Can't check myself, I'm not using the prebuild packages, but enjoy building stuff myself with clang :)

          (Z(:^

          1 Reply Last reply
          0
          • B Offline
            B Offline
            blindflyer
            wrote on last edited by
            #6

            IMHO the bug is in the fact that qmake does not add an include for QtWidgets in the Makefile if you put QT += widgets in the .pro file.

            I know putting <QtWidgets/QMainWindow> will fix the include issue but it should not be neccessary to put <QtWidgets/...> in your source code if you put QT += widgets in your .pro file.

            QtCreator does not put <QtWidgets/...> in it's generated source code so the build of an app generated by QtCreator fails.

            1 Reply Last reply
            0
            • B Offline
              B Offline
              blindflyer
              wrote on last edited by
              #7

              As expected, both Qt 5.0.1 (+QtCreator 2.6.2) build from source or the pre-build binaries have the same issue.

              1 Reply Last reply
              0
              • sierdzioS Offline
                sierdzioS Offline
                sierdzio
                Moderators
                wrote on last edited by
                #8

                Either I misunderstand you, or you misunderstand the nature of qmake.

                QT+= widgets adds necessary calls to the Makefile so that libQtWidgets can be included and linked without hassle. You still do need to include the headers in source code. <QMainWindow> should be enough, but maybe something is wrong there.

                (Z(:^

                1 Reply Last reply
                0
                • B Offline
                  B Offline
                  blindflyer
                  wrote on last edited by
                  #9

                  In my application, if I include <QSqlRecord> I just put #include <QSqlRecord> and not #include <QtSql/QSqlRecord>. This works because I put QT += sql in my .pro file.
                  qmake adds the extra include path for QtSql, it also add the QtSql library for linking, fine.

                  I would expect the same behaviour from qmake if I put QT += widgets in my .pro file.
                  So that I only need to put #include <QMainWindow> in my source code and not #include <QtWidgets/QMainWindow>.

                  Whoever wrote QtCreator assumes the same as me because (s)he puts #include <QMainWindow> in the generated source code and not #include <QtWidgets/QMainWindow>.

                  That is why apps generated by QtCreator do not compile on Qt5.0.1.
                  But I'm repeating myself here.

                  1 Reply Last reply
                  0
                  • sierdzioS Offline
                    sierdzioS Offline
                    sierdzio
                    Moderators
                    wrote on last edited by
                    #10

                    Report it on "Jira":https://qt-project.org/wiki/ReportingBugsInQt, then.

                    (Z(:^

                    1 Reply Last reply
                    0
                    • B Offline
                      B Offline
                      blindflyer
                      wrote on last edited by
                      #11

                      Thanks. I will.

                      1 Reply Last reply
                      0
                      • B Offline
                        B Offline
                        blindflyer
                        wrote on last edited by
                        #12

                        There was an mkspec directory in my home directory.
                        This messed things up.

                        1 Reply Last reply
                        0

                        • Login

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