Upgrading QT4 project to Qt5 project

QT5 and QT4, there are a lot of changes and differences, you can refer to: changes from QT4 to QT5.
I am a computer installed Qt5.9.1, running in the c + + GUI Qt4 programming (second edition) with some problems happened when source program, this article will introduce how to upgrade to Qt5 Qt4 engineering, and run in the new version of the Qt Creator.
in the c + + GUI Qt4 programming (second edition) programs in the second chapter gotocell2 as an example, the original project directory contains the following five files:
.
and then open the gotocell2 pro file, Qt Creator will start to appear the interface for the following.

ick Configure Project to enter the Project configuration screen. In the General box, check Shadow Build, and then modify the Build Directory to suit your needs. Then click the Run button in the left toolbar.
Note: Neither the project file path nor the Build path can contain Chinese characters.

run as a result of an error, cannot find the relevant header files:
in.
solution is pro file begins with the following two lines of code:

QT += core gui
greaterThan(QT_MAJOR_VERSION, 4): QT += widgets

If you run it again, it will return an error. Because the change to the.pro file you just made requires a qmake to take effect.
In the project directory navigation window, select the project root folder ->; Right click – & gt; The Run qmake. Rerun it, and you get the desired result.

Because this project is relatively simple, the module used is few, so just modify the. Pro file can be. However, if the project is large and uses more functional modules, more modifications may be needed to run the program correctly.
#include <
#include <
#include <
#include < QtGui> change to include < QtWidgets> .


Read More: