This topic talks about the Qt Widgets changes in Qt 5. The following step-by-step instructions take you through the changes required to port the Animated Tiles application to Qt 5:
main.cpp
and replace the
#include <QtGui>
实例与
#include <QtWidgets>
. The Perl-script
fixqt4headers.pl
can be used to scan the source files of a project and perform the replacements.
animatedtiles.pro
and add
QT += widgets
towards the end of the file.
注意:
Qt GUI
is included by default in all Qt applications unless excluded using the
QT -= gui
directive in the
qmake
project file.
Once you see the application running, check whether it behaves as expected.
It is also possible to keep the project compiling with Qt 4 and Qt 5. This requires:
fixqt4headers.pl
script with the
--strip-modules
选项。
.pro
files:
greaterThan(QT_MAJOR_VERSION, 4): QT += widgets
#if
scopes around code using modified API:
#if QT_VERSION >= 0x050000 headerView - > setSectionResizeMode( QHeaderView :: ResizeToContents); #else headerView - > setResizeMode( QHeaderView :: ResizeToContents); #endif
if you are using Qt WebKit ,见 Qt WebKit to Qt WebEngine porting instructions.