Please nominate your Qt Champions for 2021! https://forum.qt.io/topic/132134/looking-for-the-2021-qt-champions
Issues migrating from Qt 4.8.1 to Qt 5
I worked for several months with Qt 4.8.1. 3 days ago I also installed Qt 5. My computer is a Windows 7 64 bit machine. I installed WinSDK containing MSVC compilers. At first compilers were not detected so I added the file as described on the known issues page.
Qt 5 detects now the compilers and also the path to Qmake. However I get these 12 strange error messages when I try to compile the project which I developed with Qt 4.8.1. I tried to deinstall Qt 4.8.1 but this didn't help.
C:\Users\owner\project\main.cpp:1: error: C1083: Cannot open include file: 'QtGui/QApplication': No such file or directory
c:\users\owner\project\mainscreen.h:4: error: C1083: Cannot open include file: 'QMainWindow': No such file or directory
c:\users\owner\project\nominalscale.h:4: error: C1083: Cannot open include file: 'QWidget': No such file or directory
Does anybody know how to solve this issue?
elpuri last edited by
All the QWidgets related stuff is now in it's own module. You need to add "QT += widgets" to your .pro file.
Is your path environment variable set to the new bin location for Qt5 (appended to the path variable)? I haven't ventured into Qt5 yet though.
I added C:\Qt\Qt5.0.0\5.0.0\msvc2010\bin to the path but this didn't help...
I also added QT += widgets to the pro file but this also didn't help ...
Is that the actual install location you used?
For 4.8.4 I use the default:
Not all the sub folders...
Double check your install location on your C drive.
This is the actual install location, all these subfolders were created by Qt 5 installer ...
Sorry, again, I haven't used Qt5 yet. Can you show your .pro file? That might help with figuring out if it is a linking issue.
This is the full content of my pro file:
Project created by QtCreator 2012-10-14T13:28:45
QT += core gui widgets
TARGET = Project
TEMPLATE = app
SOURCES += main.cpp
HEADERS += mainscreen.h
FORMS += mainscreen.ui
I just checked out an example from Qt5 here.
compare the includes from what you have and what they have for a main window application.
<QtWidgets> is an include in Qt5 instead of <QWidget>
<QApplication> is an include in Qt5 instead of <QtGui/QApplication>
and so on.
Hope this helps.
The errors which I mentioned first disappeared after including QtWidgets etc. in the includes in the header files. Thanks!!
Afterwards, I now still have about 8 error messages of the following type:
C:\Users\owner\project\conceptualscaling.cpp:2: error: C1083: Cannot open include file: 'ui_conceptualscaling.h': No such file or directory
I tried creating a new form designer widget which has this include "ui_formtest.h" in the cpp and this new Widget does not have this error message.
Do you have any suggestions on how to solve this for my 8 designer form classes which already exist?
I managed to solve all problems some time ago so I will share it with you in case somebody can benefit from it:
- I added QT+= qtwidgets to the pro file and had to change all imports such as the views and models I used to <QtWidgets/...>
- <QPrinter> didn't work anymore so I had to include <QtPrintSupport/QPrinter> and also QT += qprintsupport to the pro file
- Custom data types don't work anymore in signals and slots without registering them as a metatype
- If you have ui files from a older Qt project, I found no beter solution than to remove them and code everything in them manually.
The code is now almost twice as fast for certain sub parts of the system.