New Features in Qt 6.0
The product mission of Qt 6 is to enable Qt to be the productivity platform for the future. Qt 6.0, as a major release of Qt, provides a higher degree of freedom to implement new features, functionality, and better support today and tomorrow's requirements. Qt 6.0 is a continuation of the Qt 5 series and should not be disruptive for users to migrate on.
When creating Qt 6, we have especially wanted to ensure that the core values that Qt has for our customers and users are adhered to:
- Its cross-platform nature, allowing users to deploy their applications to all desktop, mobile, and embedded platforms using one technology and from a single code base
- Its scalability from low-end, single-purpose devices to high-end complex desktop applications or connected system
- World-class APIs and tools and documentation, simplifying the creation of applications and devices
- Maintainability, stability, and compatibility, allowing to maintain large code bases with minimal effort
- A large developer ecosystem with more than 1.5 million users
Qt 6.0 is the first release of the Qt 6 series addressing new market demands while keeping the core values at the heart of what we're doing.
- 1 Porting guide
- 2 Overview of the changes
- 3 New Features (within existing modules)
- 4 New Modules
- 5 Platform Changes
- 6 Removed Modules
- 7 Additional Modules Available via Package Manager
When creating Qt 6, we aim to retain as much compatibility with Qt 5 as possible, but some changes were inevitable to make Qt a better framework. To make it easier to port to Qt 6.0, we have created a Porting guide to summarize those changes and provide guidance to handle them. In the guide, you can find links to articles about changes that may affect your application and help you transitioning from Qt 5 to Qt 6.
Overview of the changes
Key changes in Qt 6.0 include:
- Leveraging C++17
- Next generation QML
- New graphics architecture
- Unified 2D and 3D for Qt Quick
- CMake build system (with qmake still supported for applications)
- Multiple improvements throughout
With Qt 6.0 focus is in the most commonly used modules, so many of the add-ons are not yet available with Qt 6.0.
New Features (within existing modules)
There have been lots of clean-up rounds, and we have removed many deprecated methods. The Qt 6 documentation snapshot pages, automatically generated by QDoc based on the code, include Obsolete Classes and New Classes and Functions lists.
- QtConcurrent::run() has the following improvements:
- It now works with a variable number of arguments
- It provides access to the promise object associated with the given task inside the run() method. This allows to do progress reporting, report multiple results, suspend or cancel the execution of run().
- All the QtConcurrent methods have been improved to do perfectly forward the passed parameters and avoid extra copies.
- A new QtConcurrent::task() method has been added to QtConcurrent, which provides a fluent interface for running a task in a separate thread.
- View class changes
- QByteArrayView now provides a light-weight way to view the content of a QByteArray or other char-equivalent array data
- QStringView received multiple API improvements
- QUtf8StringView references a contiguous portion of a UTF-8 string without having to construct a QString or QByteArray
- QAnyStringView references a strings of any of the following encodings: UTF-8, UTF-16, and Latin-1.
- QStringRef was moved to the new Qt Core5Compat module.
- QPromise allows setting values, progress and exceptions to QFuture
- QFuture supports attaching continuations
- QStateMachine was removed from Qt Core and will return in later Qt releases (most likely as part of the Qt SCXML module)
- Signals can now be converted to QFuture objects
- QVector and QList are unified. QList is updated and should be used by default when array-like behaviour is needed
- QList, QString and QByteArray now have optimized complexity of insertion at the beginning (a.k.a. prepend)
- Q_DECLARE_TYPEINFO() mechanism simplified:
- Trivially copyable and trivially destructible types are automatically treated as relocatable (Q_RELOCATABLE_TYPE)
- Q_MOVABLE_TYPE and Q_RELOCATABLE_TYPE mean the same thing
- Container classes now use qsizetype as an underlying type for size and indexing. Additionally, several related classes got updated in a similar fashion (e.g. QTextBoundaryFinder and QRegularExpression). This change allows containers to hold more than 2^31 items on 64 bit platforms
- QLocale improvements, principally around number formatting (plus lots of clean-up).
- QHash and related classes have been improved
- For custom types, QHash and QMultiHash rely on you providing a custom qHash() function in the same namespace. In Qt 4 and Qt 5, the return value and optional second argument of a qHash function was of type uint. In Qt 6, it is size_t.
- The implementation of QHash and QMultiHash in Qt 6 got changed from a node based approach to a two stage lookup table
- QMultiHash no longer derived from QHash. QHash:insertMulti() was removed subsequently.
- The QProcess::start() overload that interprets a single command string by splitting it into program name and arguments is renamed to QProcess::startCommand()
- The meta type system and QVariant have been improved. Highlights include the ability to create a QMetaType at compile-time from any type, the unification of the treatment of built-in and user types as well as QVariant being faster.
- QDBusPendingReply has been changed to be a variadic template class in order to support more than 8 template parameters now
- The QDBusConnection::sender() function has been removed.
- The QDBusArgument::operator<<() specializations for QHash, QMap and QList have been unified into common specializations for associative containers
- The QDBusMessage::call() and QDBusMessage::asyncCall() methods with a fixed size of arguments have been removed
- QPageRanges is a new class that helps with managing a collection of page ranges, i.e. when printing
- The Markdown parser now distinguishes _underlined_ text from *emphasized* (italic) text by default. Old behavior (using italics for both) can be restored by omitting the FeatureUnderline flag.
Input event improvements
In the past, mouse, tablet and touch events were quite different, because only touchscreens are multi-touch, and therefore only QTouchEvent could carry multiple touchpoints; while tablet devices have other capabilities. Now we have refactored the pointing-device events to have common API in addition, so that it's possible to write device-agnostic event handling code. This provides the foundation to make event handling more uniform in Qt Quick.
- QPointerEvent is the new class that provides common API for input events from pointer-based input devices, such as mice, tablets, or touch screens.
- QSinglePointEvent is a new subclass that provides a common set of accessors for input events from single-point devices: that is, all devices except touchscreens. QMouseEvent is now a trivial subclass of QSinglePointEvent.
- QEventPoint stores information about an individual event point. QTouchEvent carries multiple instances; QSinglePointEvent carries a single instance.
- The QInputDevice class represents the device from which each input event originates, with QPointerDevice specialising for pointer-based input devices. QInputEvent has a device() accessor. So for example when a mouse event is synthesized from a touch or tablet event, you can see that it came from a specific device rather than from one "core" mouse. In the future we intend to develop support for using multiple input devices simultaneously: then it will be even more important to distinguish input from different devices.
- Each platform plugin has the responsibility to create device instances as they are discovered. The known set of devices can be retrieved from QInputDevice::devices().
Classes moved from QtWidgets into QtGui
Several classes that are generally useful for UI development and didn't have a strong dependency on QWidget have been moved into the QtGui module:
- QAction and QActionGroup
- The classes from the Undo/Redo framework, such as QUndoCommand and QUndoStack
- The error() signal in QAbstractSocket was replaced by errorOccurred(). This avoids ambiguous function overloading.
- Several deprecated function from QSslSocket have been removed. QSslConfiguration should be used instead.
- Bearer Mangement and in particular he classes QNetworkConfiguration and QNetworkConfigurationManager were removed. Consequently bearer management related functions were removed from QNetworkAccessManager too.
- The default redirect policy has changed from manual to QNetworkRequest::NoLessSafeRedirectPolicy.
- QNetworkAccessManager enables HTTP/2 protocol by default.
- The QML import and versioning system has been overhauled:
- Version numbers are optional in the QML language. An import without any version number imports the latest version of the module. An import with only a major version number imports the module with specified major version and the latest minor version.
- QML supports "auto" imports: Instead of specifying a version number, one can write import <module> auto. In that case the imported module is imported in the same version as the importing module.
- qmlRegisterModuleImport() can be used to procedurally import modules (effectively doing the same as an import statement in a qmldir file).
- QJSEngine has been improved:
- QJSEngine::evaluate has a new, additional stackTrace parameter. It can be used to check if the returned QJSValue comes from an uncaught exception, and to retrieve the backtrace of the execution leading to the error.
- The static object ownership functions are available in QJSEngine, and not only in QQmlEngine.
- Color handling in QML has been improved
- The Qt.color function can be used in QML to convert color strings to actual color objects
- The QML language gained a Qt.alpha function to modify a color's alpha value
- The functions darker, lighter and tint methods have been added to the QML color object.
- The override behavior of QQmlListProperty in derived classes can be changed.
- XmlHttpRequest: It is now possible to set the User-Agent header.
- Some deprecated behavior has been removed in Qt 6.0. See the Porting Guide for more details.
- The Qt Quick scenegraph is now functional on Vulkan, Metal, and Direct3D 11, in addition to OpenGL and OpenGL ES.
- APIs with direct OpenGL dependencies are replaced by new alternatives, that are functional with all the supported graphics APIs. This affects mainly a number of member functions in QQuickWindow, QSGTexture, and QSGMaterialShader.
- The Qt Quick scenegraph material system has changed to accomodate graphics APIs other than OpenGL. QSGMaterialShader has a whole new interface to be implemented by subclasses.
- QQuickRenderControl has an enhanced API and is complemented by the new helper classes QQuickRenderTarget, QQuickGraphicsDevice, and QQuickGraphicsConfiguration, which provide better control over QQuickWindow and the underlying graphics stack.
- QQuickWindow has a number of new signals, such as beforeRenderPassRecording() or beforeFrameBegin(). These complement the existing signals, such as beforeRendering(), and enable applications to perform their own Vulkan, Metal, D3D, or OpenGL rendering before or after the Qt Quick scenegraph renders its scene.
- Vertex and fragment shaders in ShaderEffect and QSGMaterialShader are handled via the new unified shader pipeline, allowing shaders to be written once, while being functional with any of the supported graphics APIs at run time. Applications should now use the tools from the Qt Shader Tools module to prepare (compile, reflect, and translate) their shader code offline or at build time.
- The Qt Quick scenegraph renderer is now able to function in a mode that is compatible with perspective projections as well, which enables rendering combined 2D-3D scenes in one render pass.
Qt Quick 3D
- Ported to the new common graphics abstractions in Qt 6.0.
- In Qt 6.0 everything that applies to Qt Quick in this regard (for example, configuring which graphics API to use) applies to Qt Quick 3D as well. The 3D scene renderer plugs in to Qt Quick, using the same rendering infrastructure, unlike Qt 5.15, where rendering happened in separate worlds by going directly to OpenGL.
- More unified 2D-3D scenes.
- A 3D scene can contain arbitrary Item (QQuickItem) subtrees, which are then rendered directly by the Qt Quick scenegraph's renderer, using the appropriate transformations and projections, without having to do a separate render pass into some offscreen render target.
- Improved rendering fidelity
- Improved PrincipledMaterial: assets with the metallic-roughness workflow now look closer to what the designer intended.
- Enhanced color handling (linear vs. sRGB), with proper tonemapping.
- The custom material system has been completely redesigned. The CustomMaterial API and the way the associated shader snippets are written have major changes in Qt 6.0. See also the getting started page.
- Post-processing effects have been migrated to a shader handling approach that follows the same patterns as CustomMaterial, making writing custom effects simpler.
- Texture parameters (filtering, mipmaps) are now configurable via the QML API.
- Added a C++ API for procedurally generating image data for textures.
- Updated the custom geometry C++ API.
- The documentation has been heavily updated. Also added architecture documentation and getting started guides.
Qt Quick Controls
- Added macOS and Windows native desktop styles.
- A style appropriate for the target platform is now selected if none is specified. To support this, the Default style was renamed to Basic.
- Compile time style selection is now supported by explicitly importing a style.
Added implicitContentWidthPolicy to ComboBox, which controls how its implicitContentWidth is calculated. This can be used to automatically ensure that text is not elided.
Qt Wayland Compositor
- Added support for advertising multiple client buffer integrations in the same compositor. QT_WAYLAND_CLIENT_BUFFER_INTEGRATION will now accept a semicolon-separated list.
- Added a new input method protocol with better support for Qt's input method events and Qt Virtual Keyboard. This can be added to a compositor by instantiating the QtTextInputMethodManager type.
- Added API for selecting supported wl_shm formats.
- Added support for wl_surface.damage_buffer requests.
- The return type for boundValues() has been changed from QMap<QString, QVariant> to a QVariantList
- QSqlField now uses QMetaType to define the type of a field instead of QVariant::Type.
- QTest::QTouchEventSequence functions taking a QWidget parameter has been moved to the new class QTest::QTouchEventWidgetSequence
- The SAX classes have been removed. Please use QXmlStreamReader to read XML files.
- Those classes in the QtSvg module that depend on QtWidgets have been moved into a separate
QtSvgWidgetslibrary, so it's now possible to use much of the QtSvg functionality in Qt Quick based applications without pulling in a QtWidgets dependency.
- For applications that require integration with OpenGL, the OpenGL module contains convenience classes to make this type of integration easier and faster. Classes that depend on QtWidgets live in a separate
QtOpenGLWidgetslibrary so that Qt Quick based applications can use the convenience classes to integrate with OpenGL, without pulling in a QtWidgets dependency.
- Qt OpenGL now contains the QOpenGL* classes from Qt Gui in Qt 5. The deprecated QGL* set of classes has been removed.
- Several widget-independent classes have been moved out of QtWidgets and into QtGui (see above)
- On system with multiple displays, use QWidget::setScreen to specify on which display the widget should show; the QDesktopWidget class has been removed
- The APIs in the Qt PrintSupport module have been consolidated and cleaned up for increased consistency
- Compatibility library providing access to legacy APIs removed in Qt 6.
- Tools and APIs for preparing graphics and compute shaders to be consumed by the new graphics stack
- Qt is now built with CMake.
- Qt High DPI scaling is now activated by default; the default rounding policy is PassThrough
- Platform specific APIs are now available though the new native interfaces API
- Renamed Java package name from org.qtproject.qt5.android to org.qtproject.qt.android. The version number will be in the name of the *.jar files instead (QTBUG-86969).
- Use Gradle daemon for Android app builds (QTBUG-86674).
- Set default javac source and target build versions to 8 and allow setting that from configure script (QTBUG-86282).
- Minimum Android API level is 23 for Qt 6.
- Implement MaximizeUsingFullscreenGeometryHint to allow Android apps to go into immersive mode (QTBUG-74202).
- Fixes to androidtestrunner and running QML tests.
The following modules are removed and not planned to be developed further. Other modules that are not part of Qt 6.0 are considered for candidates to support with later Qt 6.x releases or as additional libraries on top of the baseline Qt release.
- Qt Multimedia Widgets
- Qt Graphical Effects
- Qt Purchasing
- Qt Quick Extras
- Qt Quick WebGL
- Qt Script
- Qt XML Patterns
- Qt Platform Headers
See Checklist for Qt 6.0 inclusion for the selection process.
Code from these Qt <platform> Extras modules will find new homes in more relevant modules over time, and any remaining APIs considered for inclusion in later 6.x releases:
- Qt Android Extras
- Qt Mac Extras
- Qt X11 Extras
- Qt Windows Extras
Additional Modules Available via Package Manager
The following additional modules are available via the package manager functionality in the Qt online installer:
- Qt Image Formats
- Qt 3D
- Qt Network Authorization
The package manager provides these additional modules as source packages, which need to be built locally by the user.