New Features in Qt 6.0

From Qt Wiki
Jump to navigation Jump to search

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.

Porting guide

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.

Qt Concurrent

  • 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.

Qt Core

  • 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.

Qt DBus

  • 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

Qt Gui

  • 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:

Qt Network

  • 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.

Qt QML

  • 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.

Qt Quick

  • 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.

Qt SQL

  • 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.

Qt Test

  • QTest::QTouchEventSequence functions taking a QWidget parameter has been moved to the new class QTest::QTouchEventWidgetSequence

Qt XML

  • The SAX classes have been removed. Please use QXmlStreamReader to read XML files.

Qt SVG

  • Those classes in the QtSvg module that depend on QtWidgets have been moved into a separate
    QtSvgWidgets
    
    library, so it's now possible to use much of the QtSvg functionality in Qt Quick based applications without pulling in a QtWidgets dependency.

Qt OpenGL

  • 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
    QtOpenGLWidgets
    
    library 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.

Qt Widgets

  • 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

Qt PrintSupport

  • The APIs in the Qt PrintSupport module have been consolidated and cleaned up for increased consistency

New Modules

Qt5Compat
Compatibility library providing access to legacy APIs removed in Qt 6.
QtShaderTools
Tools and APIs for preparing graphics and compute shaders to be consumed by the new graphics stack

Platform Changes

All

  • 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

Linux

macOS

Windows

Android

  • 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.

Removed Modules

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.

Big thanks to all the people who contributed to Qt 6.0

We have total of 274 individuals who have contributed code to Qt 6.0 (after Qt 5.15 was branched from dev):

  • Eirik Aavitsland
  • Eskil Abrahamsen Blomfeldt
  • Mike Achtelik
  • Cristian Adam
  • Chris Adams
  • Laszlo Agocs
  • Alexander Akulich
  • Dimitrios Apostolou
  • Nadim Asaduzzaman
  • Albert Astals Cid
  • Filipe Azevedo
  • Yulong Bai
  • Rolf Eike Beer
  • Leander Beernaert
  • Marco Benelli
  • Chen Bin
  • Alex Blasche
  • Gerry Boland
  • Joerg Bornemann
  • Assam Boudjelthia
  • Michael Brasser
  • Kai Uwe Broulik
  • Florian Bruhin
  • Michael Brüning
  • Oswald Buddenhagen
  • Andreas Buhr
  • Giulio Camuffo
  • Gustavo Carneiro
  • Juan Casafranca
  • Jean-Michaël Celerier
  • Nie Cheng
  • Helio Chissini de Castro
  • Ryan Chu
  • Wang Chuan
  • Xie Chuan
  • Wang ChunLin
  • Miguel Costa
  • Alexandru Croitor
  • Mitch Curtis
  • Thibaut Cuvelier
  • Giuseppe D'Angelo
  • José Dapena Paz
  • Vincas Dargis
  • Paolo Dastoli
  • Szabolcs David
  • Aaron Dewes
  • VaL Doroshchuk
  • Ole-Morten Duesund
  • Evgeniy A. Dushistov
  • Alexey Edelev
  • David Edmundson
  • Christian Ehrlicher
  • Iikka Eklund
  • Volker Enderlein
  • Ales Erjavec
  • Ömer Fadıl USTA
  • Vitaly Fanaskov
  • David Faure
  • Ilya Fedin
  • Nicolas Fella
  • Jesus Fernandez
  • Pier Luigi Fiorini
  • Takao Fujiwara
  • Kevin Funk
  • Samuel Gaist
  • Roman Genkhel
  • Lucie Gérard
  • Aleksei German
  • Christophe Giboudeaux
  • Frederik Gladhorn
  • Olivier Goffart
  • Maximilian Goldstein
  • Andrei Golubev
  • Robert Griebl
  • Kaj Grönholm
  • Adriaan de Groot
  • Henning Gruendl
  • Jan Grulich
  • Federico Guerinoni
  • Nicolas Guichard
  • Richard Moe Gustavsen
  • Ralf Habacker
  • Tang HaiXiang
  • Heikki Halmet
  • Zhang Hao
  • Sean Harmer
  • Andre Hartmann
  • Thomas Hartmann
  • Andreas Hartmetz
  • Sebastian Hartte
  • Simon Hausmann
  • Jani Hautakangas
  • Jani Heikkinen
  • Miikka Heikkinen
  • Christian Heimlich
  • Karsten Heimrich
  • Ulf Hermann
  • Volker Hilsheimer
  • Teemu Holappa
  • Dominik Holland
  • Sze Howe Koh
  • Tobias Hunger
  • Unai IRIGOYEN
  • Linus Jahn
  • Martin Jansa
  • Nils Jeisecke
  • Allan Sandfeld Jensen
  • Morten Johan Sørvig
  • Juan José Casafranca
  • Jaeyoon Jung
  • Daniel Kahn Gillmor
  • Maurice Kalinowski
  • Alexander Kanavin
  • Jonas Karlsson
  • Alexander Kartashov
  • Jeremy Katz
  • Dmitry Kazakov
  • Aapo Keskimolo
  • Steffen Kieß
  • Friedemann Kleint
  • André Klitzing
  • Michal Klocek
  • Johan Klokkhammer Helsing
  • Andreas Klots
  • Lars Knoll
  • Jarek Kobus
  • Kai Koehne
  • Antti Kokko
  • Martin Koller
  • Fabian Kosmale
  • Miłosz Kosobucki
  • Volker Krause
  • Marcel Krems
  • Anton Kreuzkamp
  • Mike Krus
  • Anton Kudryavtsev
  • Sona Kurazyan
  • Timo Lang
  • Elvis Lee
  • Inho Lee
  • Eric Lemanissier
  • Werner Lemberg
  • Paul Lemire
  • Steve Lhomme
  • Thorbjørn Lindeijer
  • Robert Loehning
  • Antti Määttä
  • Thiago Macieira
  • Kyu Man Lim
  • Hiweed Mandriva
  • Sandro Mani
  • Alberto Mardegan
  • Marco Martin
  • Sérgio Martins
  • Thorbjørn Lund Martsum
  • Vikke Matikainen
  • Cristián Maureira-Fredes
  • Kylie McClain
  • James McDonnell
  • Mason McParlane
  • René Meusel
  • Piotr Mikolajczyk
  • Fawzi Mohamed
  • Jesko von Monkiewitsch
  • Bartlomiej Moskal
  • Marc Mutz
  • Andy Nichols
  • Aleksei Nikiforov
  • Yuya Nishihara
  • Mårten Nordheim
  • Jędrzej Nowacki
  • Kari Oikarinen
  • Tapio Oksa
  • Gatis Paeglis
  • YoungSun Park
  • Jerome Pasion
  • Kai Pastor
  • Andrew Patterson
  • Wang Peng
  • Miika Pernu
  • Samuli Piippo
  • Timur Pocheptsov
  • Joni Poikelin
  • Guy Poizat
  • Aleix Pol
  • Alessandro Portale
  • Lorn Potter
  • Jordi Pujol Foyo
  • Liang Qi
  • David Redondo
  • Topi Reinio
  • Topi Reiniö
  • Alex Richardson
  • Frank Richter
  • Laurent Rineau
  • Konstantin Ritt
  • Andre de la Rocha
  • Christian Romberg
  • Raphael Rosch
  • Shawn Rutledge
  • Otto Ryynänen
  • Toni Saario
  • Jan Arve Sæther
  • Rob Samblanet
  • Ahmad Samir
  • Tony Sarajärvi
  • Christoph Schleifenbaum
  • Lars Schmertmann
  • Julien Schueller
  • Andreas Schwab
  • Carl Schwan
  • Peter Seiderer
  • JeongBong Seo
  • Dmitry Shachnev
  • Nick Shaforostov
  • Orgad Shaneh
  • Andy Shaw
  • Konstantin Shegunov
  • Zhang Sheng
  • Xu Shitong
  • Venugopal Shivashankar
  • David Skoland
  • Daniel Smith
  • Martin Smith
  • Ivan Solovev
  • Mateusz Starzycki
  • Christian Stenger
  • Martin Storsjö
  • Christian Strømme
  • Tarja Sundqvist
  • Tasuku Suzuki
  • Mikhail Svetkin
  • Nodir Temirkhodjaev
  • Hikaru Terazono (3c1u)
  • Ivan Tkachenko
  • Alex Trotsenko
  • Shantanu Tushar
  • Paul Olav Tvete
  • Jüri Valdmann
  • Peter Varga
  • BogDan Vatra
  • Erik Verbruggen
  • Doris Verria
  • Nico Vertriest
  • Tor Arne Vestbø
  • Kalle Viironen
  • Sander Visser
  • Jannis Voelker
  • Valery Volgutov
  • Alexander Volkov
  • Ville Voutilainen
  • Michael Weghorn
  • Paweł Wegner
  • Wang Wei
  • Edward Welbourne
  • Peng Wenhao
  • Paul Wicking
  • Milian Wolff
  • Oliver Wolff
  • Li Xinwei
  • Liu Yang
  • Lu YaNing
  • Stanislav Yelenskiy
  • Zhang Yu
  • Vlad Zahorodnii
  • JiDe Zhang
  • Jide Zhang
  • Pengfei Zhang
  • Yuhang Zhao
  • Li Zhong Ming
  • Михаил Светкин
  • hjk
  • jiu
  • MagnaboscoL

In addition we have several thousands of people who have tested the pre-releases to help catch the bugs and provided valuable feedback via Qt Project forums, mailing lists, bug reports and other channels. We also have a large number of people who have throughout the years contributed to Qt and thus helped to form the foundation upon which Qt 6.0 is built.

Your work is highly appreciated!