Qt5 cannot include the file QMainWindow



  • 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.



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



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



  • 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.
    @



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



  • [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.



  • 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.



  • [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.



  • 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.



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



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


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.