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. Qt5 cannot include the file QMainWindow
Forum Updated to NodeBB v4.3 + New Features

Qt5 cannot include the file QMainWindow

Scheduled Pinned Locked Moved General and Desktop
11 Posts 5 Posters 19.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.
  • E Offline
    E Offline
    Essviv
    wrote on last edited by
    #1

    I have recently installed both Qt4.8.4 and Qt5.0.0 on my computer.Everything goes well with the version 4.8.4 while something wired exists when compiling with library v5.0.0. I created a new project with QtCreator2.6.1 under the D:\ and then the compiler complained it couldn't include the QMainWindow file. Then i removed the same project into the C:\ and everything was fine. Anyone here has any ideas about the wired problem? Thanks a lot.

    1 Reply Last reply
    0
    • E Offline
      E Offline
      Essviv
      wrote on last edited by
      #2

      I have checked the pro file and the "greaterThan(QT_MAJOR_VERSION, 4): QT += widgets" does exist...

      1 Reply Last reply
      0
      • L Offline
        L Offline
        lgeyer
        wrote on last edited by
        #3

        Please post the compiler command which gets executed when building the project on drive D.

        1 Reply Last reply
        0
        • S Offline
          S Offline
          soroush
          wrote on last edited by
          #4

          I have same problem here. Compiling a Qt project located in any partition else than "C" , the compiler can't see headers. Qt itself is compiled in E. MinGW is located at C.

          For example:

          @
          21:33:22: Starting: "C:\mingw-x64\bin\mingw32-make.exe"
          cd agt-test\ && ( if not exist Makefile E:\x64\qt-5.0.0\bin\qmake.exe E:\workspace\agt-project\agt-test\agt-test.pro -spec win32-g++ CONFIG+=release -o Makefile ) && C:/mingw-x64/bin/mingw32-make -f Makefile
          mingw32-make[1]: Entering directory 'E:/workspace/agt-project-release/agt-test'
          C:/mingw-x64/bin/mingw32-make -f Makefile.Release
          mingw32-make[2]: Entering directory 'E:/workspace/agt-project-release/agt-test'
          g++ -c -pipe -fno-keep-inline-dllexport -O3 -mtune=core2 -frtti -Wall -Wextra -fexceptions -mthreads -DUNICODE -DQT_NO_DEBUG -DQT_GUI_LIB -DQT_CORE_LIB -DQT_NEEDS_QMAIN -I....\agt-project\agt-test -I"....\agt-project\agt-plugin" -I"....\agt-project\agt-plugin\release" -I"......\x64\qt-5.0.0\include" -I"......\x64\qt-5.0.0\include\QtGui" -I"......\x64\qt-5.0.0\include\QtCore" -I"release" -I"." -I"......\x64\qt-5.0.0\mkspecs\win32-g++" -o release\main.o ....\agt-project\agt-test\main.cpp
          ....\agt-project\agt-test\main.cpp:1:24: fatal error: QApplication: No such file or directory
          compilation terminated.
          @

          But in C:\

          @
          mingw32-make[1]: Entering directory 'C:/Program Files/Qt Creator/untitled-build-Desktop-Release'
          E:\x64\qt-5.0.0\bin\uic.exe ..\untitled\mainwindow.ui -o ui_mainwindow.h
          g++ -c -pipe -fno-keep-inline-dllexport -O3 -mtune=core2 -frtti -Wall -Wextra -fexceptions -mthreads -DUNICODE -DQT_NO_DEBUG -DQT_WIDGETS_LIB -DQT_GUI_LIB -DQT_CORE_LIB -DQT_NEEDS_QMAIN -I..\untitled -I"E:\x64\qt-5.0.0\include" -I"E:\x64\qt-5.0.0\include\QtWidgets" -I"E:\x64\qt-5.0.0\include\QtGui" -I"E:\x64\qt-5.0.0\include\QtCore" -I"release" -I"." -I"." -I"E:\x64\qt-5.0.0\mkspecs\win32-g++" -o release\main.o ..\untitled\main.cpp
          g++ -c -pipe -fno-keep-inline-dllexport -O3 -mtune=core2 -frtti -Wall -Wextra -fexceptions -mthreads -DUNICODE -DQT_NO_DEBUG -DQT_WIDGETS_LIB -DQT_GUI_LIB -DQT_CORE_LIB -DQT_NEEDS_QMAIN -I..\untitled -I"E:\x64\qt-5.0.0\include" -I"E:\x64\qt-5.0.0\include\QtWidgets" -I"E:\x64\qt-5.0.0\include\QtGui" -I"E:\x64\qt-5.0.0\include\QtCore" -I"release" -I"." -I"." -I"E:\x64\qt-5.0.0\mkspecs\win32-g++" -o release\mainwindow.o ..\untitled\mainwindow.cpp
          E:\x64\qt-5.0.0\bin\moc.exe -DUNICODE -DQT_NO_DEBUG -DQT_WIDGETS_LIB -DQT_GUI_LIB -DQT_CORE_LIB -DQT_NEEDS_QMAIN -I..\untitled -I"E:\x64\qt-5.0.0\include" -I"E:\x64\qt-5.0.0\include\QtWidgets" -I"E:\x64\qt-5.0.0\include\QtGui" -I"E:\x64\qt-5.0.0\include\QtCore" -I"release" -I"." -I"." -I"E:\x64\qt-5.0.0\mkspecs\win32-g++" -D__GNUC__ -DWIN32 ..\untitled\mainwindow.h -o release\moc_mainwindow.cpp
          g++ -c -pipe -fno-keep-inline-dllexport -O3 -mtune=core2 -frtti -Wall -Wextra -fexceptions -mthreads -DUNICODE -DQT_NO_DEBUG -DQT_WIDGETS_LIB -DQT_GUI_LIB -DQT_CORE_LIB -DQT_NEEDS_QMAIN -I..\untitled -I"E:\x64\qt-5.0.0\include" -I"E:\x64\qt-5.0.0\include\QtWidgets" -I"E:\x64\qt-5.0.0\include\QtGui" -I"E:\x64\qt-5.0.0\include\QtCore" -I"release" -I"." -I"." -I"E:\x64\qt-5.0.0\mkspecs\win32-g++" -o release\moc_mainwindow.o release\moc_mainwindow.cpp
          g++ -Wl,-s -Wl,-subsystem,windows -mthreads -o release\untitled.exe release/main.o release/mainwindow.o release/moc_mainwindow.o -lglu32 -lopengl32 -lgdi32 -luser32 -lmingw32 -lqtmain -LE:/x64/qt-5.0.0/lib -lQt5Widgets -lQt5Gui -lQt5Core
          mingw32-make[1]: Leaving directory 'C:/Program Files/Qt Creator/untitled-build-Desktop-Release'
          21:34:10: The process "C:\mingw-x64\bin\mingw32-make.exe" exited normally.
          @

          1 Reply Last reply
          0
          • U Offline
            U Offline
            utcenter
            wrote on last edited by
            #5

            This is odd, my build has no problems with finding regardless of where the project files are.

            1 Reply Last reply
            0
            • S Offline
              S Offline
              soroush
              wrote on last edited by
              #6

              [quote author="utcenter" date="1358279621"]This is odd, my build has no problems with finding regardless of where the project files are.[/quote]

              Yes, that's odd for me too. I'm not a Windows guy. I hate that OS. Even can't move my Qt from PC that I've compiled to my laptop ("discussed here":http://qt-project.org/forums/viewthread/23676/)

              Any help is welcome.

              1 Reply Last reply
              0
              • L Offline
                L Offline
                lgeyer
                wrote on last edited by
                #7

                qmake should generate absolute paths for -I if needed (and it does for me).

                Delete Makefile* and re-run qmake (according to the compiler command they are, however, already correct).

                Be aware that this might be just another MinGW / mingw32-make quirk. Which MinGW are you using? Try another build / revision.

                1 Reply Last reply
                0
                • S Offline
                  S Offline
                  soroush
                  wrote on last edited by
                  #8

                  [quote author="Lukas Geyer" date="1358328607"]qmake should generate absolute paths for -I if needed (and it does for me).

                  Delete Makefile* and re-run qmake (according to the compiler command they are, however, already correct).
                  [/quote]
                  Nope. Still same.
                  [quote author="Lukas Geyer" date="1358328607"]
                  Be aware that this might be just another MinGW / mingw32-make quirk. Which MinGW are you using? Try another build / revision.[/quote]

                  I'm using MinGW-builds suggested by Qt developers.

                  1 Reply Last reply
                  0
                  • L Offline
                    L Offline
                    lgeyer
                    wrote on last edited by
                    #9

                    I don't see how this can be actually caused by Qt, as the compiler command seems quite correct.
                    @
                    mingw32-make[2]: Entering directory 'E:/workspace/agt-project-release/agt-test'
                    g++ -c -pipe -fno-keep-inline-dllexport -O3 -mtune=core2 -frtti -Wall -Wextra -fexceptions -mthreads -DUNICODE -DQT_NO_DEBUG -DQT_GUI_LIB -DQT_CORE_LIB -DQT_NEEDS_QMAIN -I....\agt-project\agt-test -I"....\agt-project\agt-plugin" -I"....\agt-project\agt-plugin\release" -I"......\x64\qt-5.0.0\include" -I"......\x64\qt-5.0.0\include\QtGui" -I"......\x64\qt-5.0.0\include\QtCore" -I"release" -I"." -I"......\x64\qt-5.0.0\mkspecs\win32-g++" -o release\main.o ....\agt-project\agt-test\main.cpp
                    @
                    I still bet on (just another) a MinGW pathing quirk. You can still try another build (for example rubenvb) or another revision (rev6 has already caused a bunch of problems for me) of mingwbuilds.

                    But if this doesn't work we should probably escalate this to MinGW / mingwbuilds.

                    1 Reply Last reply
                    0
                    • I Offline
                      I Offline
                      Isachenko
                      wrote on last edited by
                      #10

                      I had the same problem.
                      I replace
                      @#include <QMainWindow>
                      @
                      with
                      @#include <QtWidgets/QMainWindow>
                      @
                      And it had solved my problem.

                      1 Reply Last reply
                      0
                      • I Offline
                        I Offline
                        Isachenko
                        wrote on last edited by
                        #11

                        I had the same problem.
                        I replace
                        @#include <QMainWindow>
                        @
                        with
                        @#include <QtWidgets/QMainWindow>
                        @
                        And it had solved my problem.

                        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