C++ API changes
Qt 5 introduces some source incompatible changes. Here we list some important ones, but you can find more complete lists in <Qt 5 Install Dir>/qtbase/dist/changes-5.x.x.
The following sections list the API changes in each module and provide recommendations for handling those changes.
Changes to Qt Core
- QLibrary::resolve() now returns a function pointer instead of
voidpointer. QLibraryInfo::buildKey()and the correspondingQT_BUILD_KEYmacro are removed. You must remove all references to this function and macro, as build key is not necessary now.- The QTranslator::translate() function signature is changed to set the default value of
nto -1. We recommend you to update the implementation of this virtual function in your sources. QBoolis removed. In Qt 4, QString::contains(), QByteArray::contains(), and QList::contains() returned an internalQBooltype so that the Qt3 codeif (a.contains() == 2)would not compile anymore. If your code usesQBool, replace it withbool.- The
QUuid::operator QString()implicit conversion operator is removed. Use the QUuid::toString() function instead. - QProcess::ForwardedChannels no longer forwards the output to the GUI applications on the Windows platform, unless those applications create a console.
QSystemLocaleis not public anymore. Use QLocale instead.- Default value of the QSortFilterProxyModel::dynamicSortFilter property is changed to
true. QTextCodecPluginis removed as all the text codecs are part of Qt Core now.QFSFileEngine,QAbstractFileEngine,QAbstractFileEngineIterator, andQAbstractFileEngineHandlerare no longer public. We recommend you to avoid using these classes as there is no compatibility promise.- qDebug(), qWarning(), qCritical(), and qFatal() are changed to macros now to track the origin of the message in source code. The information to be printed can be configured (for the default message handler) by setting the new
QT_MESSAGE_PATTERNenvironment variable. qInstallMsgHandler() is deprecated, so we recommend using qInstallMessageHandler() instead. - QPointer is changed to use QWeakPointer. The old guard mechanism has been removed, which causes a slight change in behavior when using QPointer. In earlier Qt versions, if a QPointer is used on a QWidget (or a subclass of QWidget), the QPointer was cleared by the QWidget destructor. In Qt 5, the QPointer is cleared by the QObject destructor along with the QWeakPointers. Any QPointer tracking a widget is not cleared before the QWidget destructor destroys the children for the widget being tracked.
- Qt::WFlags is deprecated, use Qt::WindowFlags instead. This typedef dates from the Qt 1 days, and such abbreviations are not current Qt style.
- Qt::HANDLE typedef is now defined as
void *on all platforms. - The non-atomic convenience methods of QAtomicInt and QAtomicPointer (that is,
operator=,operator int,operator T*,operator!,operator==,operator!=, andoperator->) have been removed as they performed implicit loads and stores of unspecified memory ordering. Code dealing with loading and storing is expected to useload(),loadAquire(),store(), andstoreRelease(), instead. - The return type of
QFlags<Enum>::operator int()matches the enum's underlying type (signed or unsigned) instead of always beingint. This allows QFlags over enums of the unsigned type (for example, Qt::MouseButton). - Because of major changes in the behavior of QTextBoundaryFinder::boundaryReasons(), the
StartWordandEndWordenum values were replaced with theStartOfItemandEndOfItemvalues to enforce revision of the affected code. - A number of functions in <QtAlgorithms> are deprecated. Use the implementations available in the STL, as described in Porting Guidelines.
setSharable()andisSharable()in Qt containers are deprecated and will be removed in Qt 6. You should not use them in new applications. If you used them in existing applications, even though they are not documented, you should port away from them.
Changes to QAction
The Softkeys API is removed, so the following functions and enums are removed:
QAction::setSoftKeyRole()QAction::softKeyRole()QAction::SoftKeyRoleQt::WA_MergeSoftkeysQt::WA_MergeSoftkeysRecursivelyQt::WindowSoftkeysVisibleHintQt::WindowSoftkeysRespondHint
Changes to QChar
QChar::NoCategoryis removed. The QChar::Other_NotAssigned enum value is returned for unassigned codepoints now.- QChar::Joining and QChar::joining() are deprecated. Use the QChar::JoiningType enum and QChar::joiningType() function instead.
Changes to QCoreApplication
- QCoreApplication::translate() no longer returns the source text if the translation is empty. Use the Qt Linguist Release tool (
lrelease -removeidentical) instead for optimization. QCoreApplication::setEventFilter()andQApplication::x11EventFilter/macEventFilter/qwsEventFilter/winEventFilterare replaced with QCoreApplication::installNativeEventFilter() and QCoreApplication::removeNativeEventFilter() for an API much closer to QEvent filtering.Note: The native events that can be filtered this way depend on the QPA backend chosen at runtime. On X11, XEvents are replaced with
xcb_generic_event_tdue to the switch to XCB, which requires porting the application code to XCB as well.QCoreApplication::TypeandQApplication::type()are removed. These Qt 3 legacy application types did not match the application types available in Qt 5. Useqobject_castinstead to dynamically find out the exact application type.- QCoreApplication::hasPendingEvents and QAbstractEventDispatcher::hasPendingEvents are deprecated.
Changes to QEvent
QEvent::AccessibilityPrepare,QEvent::AccessibilityHelp, andQEvent::AccessibilityDescriptionare removed.- QEvent::TouchCancel is introduced to use it on systems where it makes sense to differentiate between a regular QEvent::TouchEnd and abrupt touch sequence cancellations caused by the compositor. For example, when a swype gesture is recognized.
Changes to QFile
- QFile::setEncodingFunction() and QFile::setDecodingFunction() are deprecated.
- QFile::encodeName() and QFile::decodeName() are now hard-coded to operate on QString::fromLocal8Bit() and QString::toLocal8Bit() only. The old behavior is still possible using QTextCodec::setCodecForLocale(), but the new code should not make assumptions about the file system encoding and older code should remove such assumptions.
Changes to QFont
QFont::handle()is removed.- QFont::rawName() and QFont::setRawName() are deprecated.
Changes to QMetaType
QMetaType::construct()is renamed as QMetaType::create().QMetaType::unregisterType()is removed.- QMetaType now records whether the type argument inherits QObject. Such information can be useful for scripting APIs, so that custom QObject subclasses are treated as QObject pointers. For example, in Qt Script this means QScriptValue::isQObject() can be
true, where it wasfalsebefore. QMetaType::QWidgetStaris removed. Use qMetaTypeId<QWidget*>() or QVariant::canConvert<QWidget*>() instead.Q_DECLARE_METATYPE(type)now requirestypeto be fully defined. This means,Q_DECLARE_METATYPE(QSharedPointer<t>)andQ_DECLARE_METATYPE(QWeakPointer<t>)also needtypeto be fully defined. In cases where a forward declared type is needed as a meta-type, useQ_DECLARE_OPAQUE_POINTER(type).
Changes to QMetaMethod
QMetaMethod::signature()is renamed as QMetaMethod::methodSignature(), and the return type is changed to QByteArray. This change is to enable generating the signature string on demand, rather than storing it in the meta-data.- QMetaMethod::typeName() no longer returns an empty string if the return type is
void, instead it returns"void". The recommended way of checking whether a method returnsvoidis to compare the return value of QMetaMethod::returnType() with QMetaType::Void.
Changes to QObject
- QObject::connectNotify() and QObject::disconnectNotify() now need a QMetaMethod argument that identifies the signal, rather than a
const charpointer. - QObject::trUtf8() and
QCoreApplication::Encodingare deprecated. Qt assumes that the source code is encoded in UTF-8.
Changes to QVariant
- The QVariant constructor which takes Qt::GlobalColor argument is removed. Code constructing such variants must explicitly call QColor constructor now. For example, instead of
QVariant(Qt::red), useQVariant(QColor(Qt::red))to create a QVariant instance. - Implicit creation of QVariant objects from the enum values Qt::BrushStyle, Qt::PenStyle, and Qt::CursorShape has been removed. Create objects explicitly or use
static_cast<int>(Qt::SolidLine)to create a QVariant of typeintwith the same value as the enum.
Changes to QAbstractEventDispatcher
- The signature for the pure-virtual
registerTimer()function is changed. All subclasses of QAbstractEventDispatcher must re-implement the function with this new signature:virtual void registerTimer(int timerId, int interval,Qt::TimerType timerType, QObject *object) = 0;
- QAbstractEventDispatcher::TimerInfo is no longer a
typedefofQPair<int, int>. It is now astructwith 3 members:int timerId,int interval, andQt::TimerType timerType. Update the QAbstractEventDispatcher::registeredTimers() function with this change.
Changes to QDir
- The
convertSeparators()function is removed. Use QDir::toNativeSeparators() instead. - The
QDir::NoDotAndDotDotenum value is removed. Use QDir::NoDot or QDir::NoDotDot instead.
Changes to QLocale
- The QLocale data has been updated to CLDR 22.1. The historical language and country names were updated to their modern values and some deprecated names were dropped or mapped to their modern alternatives.
- The QLocale::toShort(), QLocale::toUShort(), QLocale::toInt(), QLocale::toUInt(), QLocale::toLongLong(), and QLocale::toULongLong() functions no longer take the argument for base. They localize base 10 conversions. To convert other bases, use the QString functions instead.
Changes to QAbstractItemModel
- QAbstractItemModel::beginMoveRows() no longer emits the
layoutAboutToBeChangedsignal, and QAbstractItemModel::endMoveRows() no longer emits thelayoutChangedsignal. All proxy models must connect to (and disconnect from) the QAbstractItemModel::rowsAboutToBeMoved and QAbstractItemModel::rowsMoved signals. - QAbstractItemModel::sibling() is virtual now to allow implementations to optimize based on internal data.
- QAbstractItemModel::createIndex() method now only provides the
void*andquintptroverloads, making calls with a literal0(createIndex(row, col, 0)) ambiguous. Either castquintptr(0)or omit the third argument to get thevoid*overload. - QAbstractItemModel::setRoleNames() is deprecated. Use QAbstractItemModel::roleNames() instead. QAbstractItemModel::roleNames() is virtual now to allow a consistent API with the rest of QAbstractItemModel. Reimplementing the virtual methods to provide the elements is preferred to setting those directly.
Changes to QString
- QString and QByteArray constructors now use a negative size to indicate that the string passed is null-terminated (a null-terminated array of QChar, in the case of QString). In Qt 4, negative sizes were ignored, which resulted in empty QString and QByteArray. The size argument now has a default value of
-1, replacing the separate constructors that did the same. - QString::mid(), QString::midRef(), and QByteArray::mid() now return an empty
QString,QStringRef, andQByteArrayrespectively, if the position passed is equal to the length (that is, right after the last character or byte). In Qt 4, they returned a nullQStringor a nullQStringRef. - The following QString functions use the C locale instead of the default or system locale:
- toLongLong()
- toULongLong()
- toLong()
- toULong()
- toInt()
- toUInt()
- toShort()
- toUShort()
- toDouble()
- toFloat()
This is to guarantee consistent default conversion of strings. For locale-aware conversions use the equivalent QLocale functions.
Changes to QDate, QTime, and QDateTime
- QDate only implements the Gregorian calendar, and the switch to the Julian calendar before 1582 has been removed. This means all QDate functions return different results for dates prior to 15 October 1582, and there is no longer a gap between 4 October 1582 and 15 October 1582.
- QDate::setYMD() is deprecated, use QDate::setDate() instead.
- Adding days to a null QDate or seconds to a null QTime will no longer return a valid QDate/QTime.
- The QDate::addDays() and QDateTime::addDays() functions now take a
qint64argument, and the QDate::daysTo() and QDateTime::daysTo() functions now return aqint64value. - QDate and QTime are the
userPropertyfor the QTimeEdit and QDateEdit classes, insted of QDateTime as it was for the 4.7 and 4.8 releases. The USER property for these classes was removed before Qt 4.7.0 and added again in Qt 5.0. - The serialization behavior for QDateTime is reverted to pre-Qt 5, because Qt::LocalTime is the local time (that is,
ymd hms) regardless of the underlying system time, time zone, or changes in the system zone. Therefore, the consistent behavior when serialising is to save and restore as the local time and not its UTC equivalent. This means that the QDataStream version is 14 since Qt 5.1. - The supported date range in QDateTime has been reduced to about +/- 292 million years, the range supported by the number of msecs since the Unix epoch of 1 Jan 1970 as stored in a
qint64, and as able to be used in QDateTime::setMSecsSinceEpoch() and QDateTime::toMSecsSinceEpoch(). - QDate::fromString() and QDateTime::fromString() require non-numeric date component separators when parsing Qt::ISODate. A string like 2000901901 will no longer be recognized as a valid ISO date, whereas 2000/01/01 will, even though it differs from the ISO format 2000-01-01.
Changes to QTextCodec
QTextCodec::codecForCStrings()andQTextCodec::setCodecForCStrings()are removed as they were creating uncertainty/bugs in using QString easily and (to a lesser extent) performance issues.QTextCodec::codecForTr()andQTextCodec::setCodecForTr()are removed.
Changes to QUrl
QUrl changed considerably in Qt 5 to comply better with the URL specifications and with brokenness out there. The following list summarizes the most important functional changes:
- QUrl::setPath() no longer handles relative paths. They are by definition invalid. Use the QUrl::NormalizePathSegments flag to remove /./ or /../ sequences as much as possible. It will not remove /../ from the beginning of the path.
- QUrl has been changed to operate only on percent-encoded forms. Fully-decoded forms where the percent character stands for itself, can no longer be encoded, as the getters and setters with encoded in the name are deprecated (except QUrl::toEncoded() and QUrl::fromEncoded()).
The most notable difference with this change is when dealing with QUrl::toString(). In earlier Qt versions, this function would return percent characters in the URL, but now it returns %25 like QUrl::toEncoded() does.
- QUrl no longer decodes %7B and %7D to "{" and "}" in the output of QUrl::toString().
- QUrl now defaults to decoded mode in the getters and setters for
userName,password,host,topLevelDomain,pathandfileName. This means a % in one of those fields is now returned (or set) as%rather than%25. If the former behavior was expected, passPrettyDecodedto the getter andTolerantModeto the setter. - QUrl no longer has functions that handle individual query items and query delimiters, such as
addQueryItem()andqueryPairDelimiter(). These have been moved to the new QUrlQuery class. - QUrl no longer considers all delimiter characters equivalent to their percent-encoded forms. QUrl and QUrlQuery always keep all delimiters exactly as they were in the original URL text.
- QUrl no longer supports QUrl::FullyDecoded mode in QUrl::authority() and QUrl::userInfo(), nor QUrl::DecodedMode in QUrl::setAuthority() and QUrl::setUserInfo().
- QUrl no longer decodes %23 found in the fragment to "#" in the output of QUrl::toString (
FullyEncoded) or QUrl::toEncoded().
Changes to Qt Concurrent
Qt Concurrent has been moved from Qt Core to its own module. To link against the Qt Core module, add this line to the project file:
QT += concurrent
Note: The QtConcurrent::Exception class is renamed QException and QtConcurrent::UnhandledException class is renamed QUnhandledException. They remain in Qt Core.
Changes to Qt GUI
- QPen now has a default width of 1 instead of 0. Thus, it is no longer cosmetic by default.
- QAccessibleActionInterface is now based on providing a list of action names. All functions have been changed to take arguments of type
stringinsted ofint. - The constructor of QAccessibleEvent does not need the
childparameter anymore, and the correspondingQAccessibleEvent::child()function is removed. - The constructor of QTabletEvent does not need the
hiResGlobalPosargument anymore, as all coordinates are floating point-based now. QIconEngineV2is now merged into QIconEngine. Update your sources to useQIconEngineinstead ofQIconEngineV2.- QSound is moved to Qt Multimedia from Qt GUI.
QDesktopServices::storageLocation()andQDesktopServices::displayName()are replaced by QStandardPaths::writableLocation() and QStandardPaths::displayName() respectively. They are now in the Qt Core module. Make sure to read the QDesktopServices::storageLocation() documentation when porting from QDesktopServices::DataLocation.QPixmap::grabWindow()andQPixmap::grabWidget()are removed. Use QScreen::grabWindow() instead.- The session management API has been simplified. The
commitData()function is removed and replaced by the signal QGuiApplication::commitDataRequest(). QApplication and QGuiApplication will emit this signal from 5.2 onward on supported platforms (Linux and Windows). QWidget *widget()is replaced withQObject *target()to avoid QWidget dependencies.
Changes to QAccessibleInterface
- The child integer parameters are removed to bring QAccessibleInterface closer to IAccessible2. This means that the following functions lose the integer parameter:
text(Text t, int child)is now text(Text t)rect(int child)is now rect()setText(Text t, int child, const QString &text)is now setText(Text t, const QString &text)role(int child)is now role()state(int child)is now state()
navigate()is replaced with parent() and child() to navigate the hierarchy.relationTo()is replaced with relations().QAccessibleInterface::userActionCount(),QAccessibleInterface::actionText(), andQAccessibleInterface::doAction()are removed. We recommend using the QAccessibleInterface subclasses to implement the QAccessibleActionInterface instead.
Changes to QImage
- QImage::fill() on an image with format
Format_RGB888now expects image data in RGB layout as opposed to BGR layout. This is to ensure consistency with RGB32 and other 32-bit formats. - The behavior of QImage::load(), QImage::loadFromData(), QPixmap::load(), and QPixmap::loadFromData() on a non-null image changed so that if the functions fail to load the image (return
false), the the existent image data is invalidated, so thatisNull()is guaranteed to returntruein this case.
Changes to QPainter
- QPainter does not support uniting clipped regions anymore. Use QRegion::united() instead to unite clips and pass the result to QPainter.
- QPainter fill rules when not using antialiased painting have changed so that the aliased and antialiased coordinate systems match. There used to be an offset of slightly less than half a pixel when doing sub-pixel rendering, in order to be consistent with the old X11 paint engine. The new behavior should be more predictable and give the same consistent rounding for images and pixmaps as for paths and rectangle filling. To get the old behavior, set the QPainter::Qt4CompatiblePainting render hint.
Changes to QTouchEvent
- QTouchEvent::DeviceType and QTouchEvent::deviceType() are deprecated as QTouchDevice provides a better way to identify and access the device from which the events originate.
- The constructor now takes a QTouchDevice pointer instead of
DeviceTypevalue. TouchPointStateMaskandTouchPointPrimaryare removed from the Qt::TouchPointStates enum.QTouchEvent::TouchPoint::isPrimary()is removed.
Changes to Qt Widgets
- QItemEditorFactory::createEditor() and QItemEditorFactory::valuePropertyName() signatures are changed to take arguments of type
intinstead of QVariant::Type. QInputContextis removed as related getter and setter functions in QWidget and QApplication are removed. Input contexts are now platform-specific.- QInputDialog::getInteger() is deprecated. Use QInputDialog::getInt() instead.
- The
QStyleOption*V{2,3,4}classes are removed, and their members are merged with the respective base classes. The removed classes are left as typedefs for binary compatibility. - QGraphicsItem and its derived classes can no longer pass a QGraphicsScene to the item's constructor. Construct the item without a scene and call QGraphicsScene::addItem() to add the item to the scene.
QProxyModelis removed. Use QAbstractProxyModel and the related classes instead. A copy ofQProxyModelis available in the Ui Helpers repository.
Changes to QApplication
QApplication::setGraphicsSystem()is removed, because the introduction of QPA made it redundant.QApplication::commitDataandQApplication::saveStatevirtual methods that were used for session management are removed. Connect to the QApplication::commitDataRequest and QApplication::saveStateRequest signals instead. Use QApplication::isSavingSession() if the QWidget::closeEvent if your window needs to know whether it is being called during shutdown.
Changes to QStyle
QStyle::standardIconImplementation()andQStyle::layoutSpacingImplementation()are removed, and the QStyle::standardIcon() and QStyle::layoutSpacing() functions are made pure virtual now. The removed functions were introduced in Qt 4 for binary compatibility reasons.QMotifStyle,QPlastiqueStyle,QCleanlooksStyle, andQCDEStyleare replaced with a new fusion style. If your application depends on any of these removed styles, you can either use the qtstyleplugins project to get these styles or update your application to use the new fusion style. For more details about this change, see https://blog.qt.io/blog/2012/10/30/cleaning-up-styles-in-qt5-and-adding-fusion/.- The following QStyle implementations have been made internal:
- QFusionStyle
- QGtkStyle
- QMacStyle
- QWindowsCEStyle
- QWindowsMobileStyle
- QWindowsStyle
- QWindowsVistaStyle
- QWindowsXPStyle
Instead of creating instances or inheriting these classes directly, use:
- QStyleFactory for creating instances of specific styles.
- QProxyStyle for customizing existing style implementations.
- QCommonStyle as a base for implementing full custom styles.
Changes to QHeaderView
The following functions are deprecated:
void setMovable(bool movable)- Use QHeaderView::setSectionsMovable() instead.bool isMovable() const- Use QHeaderView::sectionsMovable() instead.void setClickable(bool clickable)- Use QHeaderView::setSectionsClickable() instead.bool isClickable() const- Use QHeaderView::sectionsClickable() instead.void setResizeMode(int logicalindex, ResizeMode mode)- Use QHeaderView::setSectionResizeMode() instead.ResizeMode resizeMode(int logicalindex) const- Use QHeaderView::sectionResizeMode() instead.
Changes to QAbstractItemView
- The derived classes now emit the
clicked()signal on the left mouse click only, instead of all mouse clicks. - The virtual QAbstractItemView::dataChanged() function signature now includes the roles that have changed. The signature is consistent with the
dataChanged()signal in the model.
Changes to QColorDialog
- QColorDialog::customColor() now returns a QColor value instead of
QRgb. - QColorDialog::setCustomColor() and QColorDialog::setStandardColor() now need a QColor value as their second parameter instead of
QRgb.
Changes to Qt WebKit
- The WebKit module in Qt is now split in two modules,
webkitandwebkitwidgets, in order to allow the dependency of thewidgetsmodule to be optional. The benefits will only be available once the QQuickWebView API is made public through C++ in a future version. Thewebkitwidgetsmodule adds thewebkitmodule automatically to the project, so in your application's project file,QT += webkitshould now be modified to:QT += webkitwidgets
- The same applies to the module include,
#include <QtWebKit/QtWebKit>should be modified to:#include <QtWebKitWidgets/QtWebKitWidgets> - A consequence of the module split is that classes of the Qt WebKit API aren't all in the new module, so for a better compatibility of your application with both Qt4 and Qt5, #include <QtWebKit/QWebPage>, for example, should be included directly as:
#include <QWebPage>The include path will take care of selecting the right module.
- The qwebkitversion.h header has been renamed to qtwebkitversion.h to match other Qt modules, and part of its contents has been moved to qwebkitglobal.h.
#include <qwebkitversion.h>should be replaced with two includes:#include <qtwebkitversion.h> #include <qwebkitglobal.h>
Changes to Qt Print Support
- The
QPageSetupDialog::PageSetupDialogOptionenum and the corresponding set and get functions,QPageSetupDialog::options()andQPageSetupDialog::setOptions()are removed. - Support for printing PostScript files has been removed.
- The
QAbstractPageSetupDialogclass is removed. Use QPrintDialog instead. - The QPrintEngine::PrintEnginePropertyKey enum value
PPK_SuppressSystemPrintStatusis removed. - QPrinter no longer allows you to set an invalid printer name.
Changes to Qt Network
- The
QSsl::TlsV1enum value is renamed as QSsl::TlsV1_0. - The
QHttp,QHttpHeader,QHttpResponseHeader, andQHttpRequestHeaderclasses are removed. Use QNetworkAccessManager instead. - The
QFtpandQUrlInfoclasses are no longer exported. Use QNetworkAccessManager instead. Programs that require raw FTP or HTTP streams can use the Qt FTP and Qt HTTP compatibility add-on modules that provide theQFtpandQHttpclasses as they existed in Qt 4. - QAbstractSocket::connectToHost() and QAbstractSocket::disconnectFromHost() are virtual now, and
QAbstractSocket::connectToHostImplementation()andQAbstractSocket::disconnectFromHostImplementation()are removed. - QTcpServer::incomingConnection() now takes arguments of type
qintptrinstead of anint. QNetworkConfiguration::bearerName()is removed. Use the bearerTypeName() instead.
Changes to QSslCertificate
- QSslCertificate::subjectInfo() and QSslCertificate::issuerInfo() now return QStringList instead of a QString. This change makes searching the required information a lot easier than scanning a long string.
- QSslCertificate::isValid() is deprecated. Use QSslCertificate::isBlacklisted() instead to avoid binary breaks in the future.
- QSslCertificate::alternateSubjectNames() is deprecated. Use QSslCertificate::subjectAlternativeNames() instead.
Changes to Qt SQL
- QSqlQueryModel::indexInQuery() is virtual now.
- QSqlQueryModel::setQuery() emits fewer signals. The
modelAboutToBeReset()andmodelReset()signals are sufficient to inform views that they must re-interrogate the model. - QSqlDriver::subscribeToNotification(), QSqlDriver::unsubscribeFromNotification(), QSqlDriver::subscribedToNotifications(), QSqlDriver::isIdentifierEscaped(), and QSqlDriver::stripDelimiters() are virtual now. The corresponding
xxxImplementationfunctions are also removed as the subclasses of QSqlDriver can re-implement those directly. - QSqlError now handles alphanumeric error codes that are used by QPSQL. The numeric codes are deprecated.
Changes to Qt Test
- The plain-text, XML and lightxml test output formats are updated to include test result for every row of test data in data-driven tests. In Qt4, only fails and skips were included for individual data rows without the passes information. This limitation prevented accurate test run and pass rates calculation.
- The
QTRY_VERIFYandQTRY_COMPAREmacros are now part ofQTestLib. These macros were part oftests/shared/util.hearlier, but now they are part of the <QtTest/QtTest> header. In addition,QTRY_VERIFY_WITH_TIMEOUTandQTRY_COMPARE_WITH_TIMEOUTare provided to specify custom timeout values. - The
QTEST_NOOP_MAINmacro is removed. If a test appears to be inapplicable for a particular build at compile-time, it should be omitted either using the .pro file logic or callQSKIPin theinitTestCase()method to skip the entire test. If you're using the later approach, report a meaningful explanation in the test log. - The
DEPENDS_ONmacro is removed as it misled some users to believe that they could make test functions depend on each other or impose an execution order on test functions. QTest::qt_snprintf()is removed. This was an internal test library function that was exposed in the public API due to its use in a public macro. Any calls to this function must be replaced with QByteArray::qsnprintf().- c{QTest::pixmapsAreEqual()} is removed. Comparison of QPixmap objects must be done using the
QCOMPAREmacro, which provides more informative output in the event of a failure. - The
"mode"parameter inQSKIPmacro is removed. This parameter caused problems in test metrics calculation because of theSkipAllmode, which hid information about the skipped test data. CallingQSKIPin a test function now behaves likeSkipSingle, which is skipping a non-data-driven test function or skipping only the current data row of a data-driven test function. Every skipped data row is now reported in the test log. qCompare()has been replaced by overloading. Code such asqCompare<QString>(l, r)no longer uses the QString-specific implementation and may fail to compile. We recommend that you replace specialization with overloading. Also, rather than pass explicit template arguments toqCompare, let the overload resolution pick the correct one, and cast arguments in case of ambiguous overloads (for example,qCompare(QString(l), r)). The resulting code will continue to work against older QtTestlib versions.QTest::qWaitForWindowShown()is replaced with QTest::qWaitForWindowExposed().
Changes to Qt OpenGL
Apart from the QGLWidget class, the Qt OpenGL module should not be used for new code. Instead, use the corresponding OpenGL classes in Qt GUI.
- QGLPixelBuffer is deprecated and implemented by using a hidden QGLWidget and a QOpenGLFramebufferObject. For offscreen rendering to a texture, switch to using QOpenGLFramebufferObject directly to improve performance.
- The default major version of QGLFormat is changed to 2 to align it with QSurfaceFormat. Applications that want to use a different version, should explicitly request it using QGLFormat::setVersion().
QGLContext::generateFontDisplayLists()andQGLWidget::fontDisplayListBase()are removed.- The
listBaseparameter is removed from QGLWidget::renderText() functions. - To ensure support on more platforms, stricter requirements have been introduced for doing threaded
OpenGL. First, you must call QGLWidget::makeCurrent() at least once per each QGLWidget::swapBuffers() call, so that the platform has a chance to synchronize resizing theOpenGLsurface. Second, before calling QGLWidget::makeCurrent() or QGLWidget::swapBuffers() in a separate thread, you must call QGLContext::moveToThread() to explicitly let Qt know in which thread a QGLContext is currently being used. You also need to make sure that the context is not current in the current thread before moving it to a different thread.
Changes to Qt Global
qMacVersion()is removed. Use QSysInfo::macVersion() or QSysInfo::MacintoshVersion instead.Qt::escape()is deprecated. Use QString::toHtmlEscaped() instead.qIsDetached<>is removed, becauses it is irrelevant for multi-threaded applications. There is no replacement for this function.
Changes to Tools
- The
qttest_p4.prffile is removed. UseCONFIG+=testcaseand other flags instead. - The
-dwarf2configure argument is removed. DWARF2 is always used on macOS now. - Configure no longer calls
qmake -recursiveby default, because the subsequent build invokes qmake as needed. Use-fully-processto restore the old behavior. - The lupdate
CODECFORTRvariable is deprecated, because source code written with Qt 5 is expected to use UTF-8 encoding.