Login procedures have been improved. Check this page for details.
Transition from Qt 4.x to Qt5
| Line 1: | Line 1: | ||
| - | The transition from | + | The transition from Qt 4.x to Qt 5 is not expected to be significant. However, the "modularization" of the Qt code base requires some amount of changes to project configuration, such as use of "headers", and configuration of project build settings (such as changes to the *.pro files). |
Qt Creator (master) is compiled using Qt 4 and Qt 5; you can refer to its sources to get an overview of what is required to port an application and keep the sources backwards compatible to Qt 4. | Qt Creator (master) is compiled using Qt 4 and Qt 5; you can refer to its sources to get an overview of what is required to port an application and keep the sources backwards compatible to Qt 4. | ||
Latest revision as of 16:54, 19 April 2012
The transition from Qt 4.x to Qt 5 is not expected to be significant. However, the "modularization" of the Qt code base requires some amount of changes to project configuration, such as use of "headers", and configuration of project build settings (such as changes to the *.pro files).
Qt Creator (master) is compiled using Qt 4 and Qt 5; you can refer to its sources to get an overview of what is required to port an application and keep the sources backwards compatible to Qt 4.
Changes to *.pro Files
- QtWidgets is now a separate module:
QT += widgets
- Qt 4's QtDeclarative module is named QtQuick1 in Qt 5:
QT += quick1
A *.pro-file that works for Qt 4 and Qt 5 looks like:
greaterThan(QT_MAJOR_VERSION, 4) {
QT += widgets
QT += quick1
} else {
QT += declarative
}
Fixing #include<> Headers
A Perl script "fixqt4headers.pl" exists in qtbase/bin/. that should be run on source code using Qt that corrects the #include<> directives for Qt components to also consider the module name.
Plugin loading
The Q_EXPORT_PLUGIN,Q_EXPORT_PLUGIN2 macros have been deprecated in favor of the new Q_PLUGIN_METADATA macro. The advantage of the new system is that it allows Qt to query the metadata for the plugin without actually dlopen'ing it. This greatly improves performance and reliability of the plugin system.
The new Q_PLUGIN_METADATA macro is included next to the Q_OBJECT macro in the QObject derived class that is returned when loading the plugin. It contains the plugins IID and a filename pointing to a json file containint the metadata for the plugin. The json file is compiled into the plugin and does not need to be installed.
An example on how to change your plugins can be found by looking at the patch that changes the Gif image format plugin, see http://qt.gitorious.org/qt/qtbase/commit/963b4c1647299fd023ddbe7c4a25ac404e303c5d .