Qt 6.8 的新功能
New and Restored Modules in Qt 6.8
Qt 6.8 adds the following modules and tools:
-
The
svgtoqml
tool, used to generate QML code from SVG documents, is now out of tech preview. The tool supports a static subset of the
SVG Tiny 1.2
profile.
-
The
Qt Graphs
,
Qt HTTP Server
,
Qt Protobuf
,和
Qt GRPC
modules are all promoted out of tech preview state.
-
添加
Qt Quick Vector Image
module for displaying SVG documents as scalable vector graphics in a Qt Quick scene.
Removed Modules in Qt 6.8
The following module is deprecated. We strongly advise against using it in new code.
Qt 3D 模块
The
Qt 3D
module is deprecated. Qt 3D remains part of the licensed software, and remains part of the Qt Project. The module continues to be integrated with other modules for future releases. Critical bugs and security vulnerabilities will be addressed by the module maintainers at KDAB. Regarding new features and functionality, users should contact KDAB by emailing info@kdab.com.
New Features in Qt 6.8
Qt Core 模块
-
QChronoTimer
置换
QTimer
using std::chrono durations throughout.
-
QTimer::id
() 返回
Qt::TimerId
, introduced and accepted in place of int timer IDs in new overloads of various methods that take one.
-
More support for std::chrono durations to replace integral nanosecond parameters in
QAbstractEventDispatcher
.
-
QString
,
QByteArray
,和
QList
gain resizeForOverwrite().
-
QString
,
QByteArray
gain slice() equivalent to
*this = sliced()
.
-
QString
,
QByteArray
,
QList
,
QVarLengthArray
gain max_size() for compatibility with the Standard Template Library (STL).
-
QList
supports construction with uninitialized entries to a specified size, where the content-type permits.
-
QVarLengthArray::PreallocatedSize tells you the Prealloc parameter.
-
QLatin1StringMatcher::indexIn
() can now take a
QStringView
.
-
QCollatorSortKey
now supports move-construction.
-
QStringEncoder
and
QStringDecoder
can now take the encoding name as a
QString
.
-
QThread
gains
isMainThread
(),
isCurrentThread
().
-
QThreadPool::waitForDone
() now accepts a
QDeadlineTimer
in place of int milliseconds.
-
QDirListing
provides stl-style iteration over directory entries.
-
QVersionNumber
can now be constructed from a
QSpan
; it can also be iterated over.
-
qHash
() now accepts quint128 and qint128.
-
QMap::qHash
() tells you a key's hash value.
-
QHash
can now hash different types from its key, if they are marked as having the equivalent hash result for equivalent values (C++20 only). This works for
QString
/
QStringView
and
QByteArray
/
QByteArrayView
pairs. On all systems except on ARM processors, the
QLatin1StringView
also participates in the
QString
and
QStringView
hashing.
-
QPointF
,
QLineF
,
QRectF
,和
QMarginsF
now support fuzzy comparison and null-checks.
-
Define
QT_ENABLE_STRICT_MODE_UP_TO
to opt out of various APIs, documented by which version it cuts them out at.
-
Define
QT_NO_QASCONST
to disable qAsConst().
-
Define
QT_(NO_)USE_NODISCARD_FILE_OPEN
to control
[[nodiscard]]
on
open()
methods of I/O classes.
-
QLibraryInfo::paths
() returns all relevant paths.
-
QCryptographicHash
and
QMessageAuthenticationCode
gain
hashInto
() to compute the hash of data into a provided buffer.
-
更多
QtCore
类型采用
operator<()
now also support
operator<=>()
when compiled with C++20 (and
compareThreeWay()
even for C++17). These types now consistently support all six relational operators (as hidden friends) and the reverse of each mixed-type comparison they supported. At Qt 6.8, this applies to:
-
The
QtJniTypes
namespace, with macros to declare Java types with their JNI signature, is promoted out of technology preview and documented.
-
The variadic template versions of
QJniObject
and
QJniEnvironment
APIs are no longer preliminary and fully documented.
-
新的
QJniArray
template class makes it easy to work with Java arrays from C++ code.
Qt Graphs 模块
Qt Graphs3D
Qt Graphs2D
Qt GRPC 模块
-
Qt GRPC
is promoted out of tech preview.
-
Added streaming support to the GrpcQuick module.
-
Removed QGrpcInterceptor, QGrpcInterceptorManager and QGrpcInterceptorContinuation.
-
添加
writesDone()
method to
QGrpcClientStream
and QGrpcBidirStream to half-close a stream from the client side.
Qt GUI 模块
-
QStyleHints::colorScheme
now has a setter function that allows applications to try to override the system setting with an explicit Dark or Light scheme.
-
添加
QFont::ContextFontMerging
, which can be used to enable a new font merging algorithm that takes the full string into account when selecting fallback fonts. This may come at some more cost, but in certain cases, it will give better results.
-
添加
QFont::PreferTypoLineMetrics
style strategy, which can be set to always prefer the typographical line metrics in OpenType fonts, even if the font does not manually set the
USE_TYPO_METRICS
标志。
-
添加
QDesktopServices
custom and
https
URL scheme support for macOS, similar to what iOS has.
-
QImage::Format_CMYK8888
32bit CMYK image format has been added.
-
QColorSpace
support for ICC A2B color spaces processing has been added, along with explicit support for grayscale and CMYK color spaces.
-
添加支持
QColorSpace::Bt2020
,
QColorSpace::Bt2100Pq
,和
QColorSpace::Bt2100Hlg
HDR color spaces.
-
QColorSpace::transformModel
() returns the underlying processing model.
-
QColorSpace::colorModel
() returns which color model the color space is made for.
-
QImage::colorTransformed
() 和
QImage::applyColorTransform
() variants with three arguments has been added to support converting both image format and color space at the same time.
-
QStyleHints::contextMenuTrigger
is a writable property that allows applications to control whether context menus should be opened via button press or release.
-
Qt Accessibility interfaces now can support reporting of
属性
as key/value pairs to clients.
-
QAccessibleAnnouncementEvent
can be raised by applications to request the announcement of a message by assistive technologies.
-
QPageLayout::setMargins
now can take an optional
OutOfBoundsPolicy
parameter to indicate whether margins that are out of bounds should be rejected or clamped.
-
QPdfWriter
gained CMYK support for pens/fills.
-
QFontDatabase
gained
addApplicationFallbackFontFamily
to specify the override default fallback font families for specific scripts.
-
Completed multiview rendering support in
QRhi
. Multiview is now also supported with Vulkan 1.1 implementations, instead of requiring Vulkan 1.2. This is relevant in particular for Android-based devices such as the Meta Quest 3.
-
引入
QRhi
support for automatically resolving multisample depth (depth/stencil) rendering into a non-multisample depth (depth/stencil) texture, on platforms and APIs where this can be supported. See
QRhiTextureRenderTargetDescription::setDepthResolveTexture
() 和
QRhi::ResolveDepthStencil
了解细节。
Qt Network 模块
Qt Network Auth Module
-
添加
QOAuthUriSchemeReplyHandler
class, which handles private/custom and https URI scheme redirects (supported platforms: iOS, Android, and macOS).
-
Added Proof of Key Code Exchange (PKCE) support to the
QOAuth2AuthorizationCodeFlow
class. PKCE is a recommended security measure to mitigate authorization code interception attacks.
-
Following input from several users we went back and addressed many issues with the aim to generally improve qnetworkauth. This includes several bug fixes, improvements, deprecations, documentation additions, and also an overview documentation to help with getting started.
Qt Positioning 模块
-
The Qt Positioning Android backend can now provide altitude in
MSL format
on Android 14 and later.
Qt Protobuf 模块
-
The
Qt Protobuf
module is promoted out of tech preview.
Qt QML 模块
-
Added new features to QML Language Server: semantic highlighting, more JavaScript language support, snippet support for Quick types, documentation hints, QML file renaming,
.qmllint.ini
warning configuration support
-
Two new
CMake Policies
affecting the behavior of
qt_add_qml_module
have been added:
QTP0004
eases the use of QML modules when nested folder structures are used.
QTP0005
allows the usage of targets when specifying imports and dependencies.
Qt Quick 编译器
-
The Qml Script Compiler now records statistics about Qml to Cpp compilation. This information can be displayed by running the all_aotstats target on the project.
Qt Quick 模块
-
Added font.contextFontMerging, which can be used to enable a new font merging algorithm that takes the full text into account when selecting fallback fonts. This may come at some more cost, but in certain cases it will give better results.
-
Added font.preferTypoLineMetrics property, which can be set to always prefer the typographical line metrics in OpenType fonts, even if the font does not manually set the
USE_TYPO_METRICS
标志。
-
添加
retainWhileLoading
特性到
图像
and
BorderImage
。当设为
true
on images that load asynchronously, the current image data will be retained until the new image is fully loaded. This can avoid flickering.
-
添加
PlanarTransform
, a utility object providing simple functions for specifying 2D transformation matrices.
-
添加
PathRectangle
, an optionally rounded rectangle path for
Shape
and
PathView
.
-
添加
Drag.imageSourceSize
property to control the size of the image representing the data being dragged.
-
添加
QQuickRenderTarget::depthTexture
as a way to set a custom depth texture.
-
添加
QQuickRenderTarget::Flag
enumerator to allow specifying a view format when constructing through the named constructors.
-
TableView
now has support for programmatically and interactively moving
columns
and
rows
.
-
All standard Qt Quick items and materials are made compatible with
Multiview Rendering
. This is utilized transparently to the applications when 2D content is embedded into an Qt Quick 3D XR scene and multiview rendering is enabled. Multiview rendering can improve rendering performance and decrease power consumption of AR/VR devices.
-
Creating multiview-compatible custom materials (
QSGMaterial
,
QSGMaterialShader
) is made possible via
QSGMaterial::viewCount
().
-
Added support for directing Qt Quick rendering into a 2D texture array with
Multiview Rendering
in
QQuickRenderTarget
. This is realized via new overloads of functions such as
QQuickRenderTarget::fromVulkanImage
(), and forms the foundation of multiview rendering support for XR applications built with
Qt Quick 3D
.
-
Added support for automatically performing
multisample resolve
at the end of a render pass in
QQuickRenderTarget
. Previously multisample rendering of redirected Qt Quick scenes was only possible by targeting multisample textures, leaving resolving up to the application or its shaders. When enabled, Qt Quick will now automatically create intermediate, multisample textures for use as a color buffer, performing the resolve into the application-provided non-multisample texture automatically. This allows making Qt Quick rendering target textures provided by an external engine, framework, or API (e.g., OpenXR) that only provides and consumes non-multisample textures.
-
添加支持
setting a depth texture
in
QQuickRenderTarget
. This allows specifying the application's own texture (or texture array, when using multiview rendering) where depth data is written, instead of using Qt's own intermediate buffers. Useful in particular when depth data must be written to a depth texture provided by an external engine, framework, or API (e.g., OpenXR).
-
Added support for specifying a texture view format in
QQuickRenderTarget
. This is specified via the
viewFormat
argument in the new overloads for
QQuickRenderTarget::fromVulkanImage
() and similar. This feature is provided specifically to allow dropping or adding the sRGB qualifier from or to the texture format, and is useful when having to work with textures provided by an external engine, framework, or XR compositor, where control over the texture format is not available, yet the 3D APIs' implicit linear->sRGB conversion on shader writes is not acceptable (e.g., because the Qt Quick 3D material pipeline already performs the same operation).
-
QQuickRenderTarget
's internal management of intermediate buffers for depth/stencil and multisample color data has been redesigned. Calling
QQuickWindow::setRenderTarget
() no longer invalidates all internal temporary buffers, but rather attempts reuse as long as the size, format, and other parameters match. This is expected to lead to performance improvements in applications and libraries that have to pass in a different native texture to the
QQuickWindow
on every frame (e.g, because the texture comes from a buffer pool maintained by an external engine, framework, or XR compositor).
Qt Quick Controls 模块
-
添加
FluentWinUI3 风格
, a modern native-looking style designed for platforms running Windows 11 and above.
-
Added a new property
popupType
to
Popup
, and derived types. This can be used to control whether the popup should be in-scene, or appear in its own top-level popup window.
-
The macOS style is now capable of creating native
menus
and
menubars
.
-
The types from the (internal)
QtQuick.Controls.impl
module, such as
PaddedRectangle
or
MnemonicLabel
or similar, are
not
accidentally exposed to any document that imports
QtQuick.Controls
or any controls style anymore. Those types are private API and were never supposed to be reachable without explicitly importing
QtQuick
.Controls.impl
.
Qt Quick Shapes 模块
-
添加
ShapePath
.fillItem
property. This can be used to take any texture provider item (such as layered items and images) and use them as fill for the shape.
-
添加
ShapePath
.fillTransform
property, which can be used to set an arbitrary transform on the shape's fill, whether it is an item or a gradient.
Qt Quick 3D 模块
-
Technology Preview of XR support for Qt Quick 3D
-
Support for Head Mounted Displays (HMD) using OpenXR such as the Meta Quest 2 and 3.
-
Support for Apple Vision Pro.
-
Multi-view rendering (render both eyes in a single pass).
-
Spatial input support via hand tracking or controllers.
-
Support for spatial anchors.
-
Improved Shadow Rendering
-
Overall quality improvements.
-
Enhanced shadow debug tooling.
-
Cascading Shadow Maps.
-
Percentage-closer filtering (PCF) soft shadows.
-
PrincipledMaterial
增强
-
Additional parameters for adjusting Fresnel.
-
Support for property masking based on the vertex color attribute.
-
CustomMaterial
: expose remaining properties from
PrincipledMaterial
.
Qt Quick VectorImage Module
-
Introduced the
VectorImage
: A component which can be used to render vector graphics directly Qt Quick with hardware acceleration and no pre-rasterization. It currently supports the SVG format (a static subset of the
SVG Tiny 1.2
profile.)
-
Completed support for shaders compatible with multiview rendering. Added the
MULTIVIEW
关键词到
Qt Shader Tools 构建系统集成
.
-
Added depfile support for shaders processed at build time via
qt_add_shaders()
. Touching a file included via the
#include
directive in a shader will now trigger a recompilation of that shader file when building the project the next time.
Qt Sql 模块
-
QSqlDatabase
,
QSqlQuery
,和
QSqlDriver
gained
numericalPrecisionPolicy
.
-
QSqlDatabase
got a new function moveToThread() to change the thread affinity of the database connection.
-
The PostgreSQL and MySQL/MariaDB drivers now correctly handle dates/times when the server is in a different timezone than the client.
-
All logging is now done through categorized loggers,
qt.sql
, to improve debugging.
-
QSqlField::defaultValue
,
value
,
readOnly
,
requiredStatus
,
length
,
precision
,
generated
,
autoValue
,和
tableName
are now properties.
-
QSqlIndex::name
and
cursorName
,
QSqlQuery::forwardOnly
,和
positionalBindingEnabled
are now properties.
Qt Test 模块
-
添加
QTEST_THROW_ON_FAIL
and
QTEST_THROW_ON_SKIP
C++ macros and
environment variables
that, when defined, change how
QCOMPARE
()/
QVERIFY
()/
QSKIP
() etc exit the test function on failure. Instead of a return, exiting only the immediately-surrounding function, they throw a special exception instead, thereby exiting from sub-functions of the test function, all the way to QtTestLib.
-
The
QTRY_*_WITH_TIMEOUT
macros now also accept chrono literals (was:
int
毫秒)。
-
QTest::failOnWarning
() now has a no-parameter overload to support the common case of fail-on-any-warning, without needing to construct a match-everything regular expression.
-
QSignalSpy
no longer inherits from
QObject
. If your code uses the fact that
QSignalSpy
is-a
QObject
, you need to redesign around this now.
-
The
QSignalSpy::signal
() method no longer necessarily returns an empty byte array when the connection failed. Use the existing
isValid
() method to determine whether a given
QSignalSpy
object listens to a valid signal on a valid object.
-
The QCOMPARE_xx macros can now only find
QTest::toString
() expansions that are either found via Argument Dependent Lookup on the type in question or are an instantiation of the
QTest::toString
<T>() template. This matches the behavior of the
QCOMPARE
() 宏。
Qt WebEngine 模块
QDoc 文档编制生成器
-
现在可以使用
\keyword
command to link to a section title, as a means to improve context sensitive help.
-
QDoc no longer incorrectly links to non-existing documentation for undocumented property access functions.
-
The build system no longer defines
QDOC2_COMPAT
.
-
When generating DocBook output, QDoc no longer escapes characters multiple times.
-
The
\instantiates
command is deprecated. Use the new
\nativetype
command instead. The old command now delegates to the new one, and QDoc generates a notice about its deprecation.
-
You can specify
auto
as return type for functions as a way to mask the full type in the generated documentation.
-
Improved formatting of the requisites table in API documentation.
-
QDoc generates less duplicate reports in its output to stdout.
-
.qhp files now (correctly) contain entries for group items created with the
\ingroup
command when there is no related
\group
文档编制。
-
QDoc now generates titles for namespaces in .qhp files, not just for classes and types.
-
QDoc now correctly parses
-DDEFINE=VALUE
命令行选项。
-
QDoc generates new warnings if:
-
qhp subproject indexTitle attribute isn't found.
-
若
\nativetype
command is used multiple times for the same C++ class.
-
When generating a file multiple times per project.
-
Functions previously selected as an overload that aren't explicitly marked with the
\overload
command, that due to sorting changes are selected as the primary signature. They must either be documented in full or tagged with the
\overload
命令。
-
QDoc no longer warns about undocumented parameters in overloaded constructors, and some unnecessary link warnings were removed.
-
Link warnings now report sensible locations.
-
QDoc now requires Clang 17 or newer.
-
The QDoc manual received multiple updates.
-
You can tag trademarks with the new
\tm
command. If you define the configuration variable
navigation.trademarkspage
, the trademark symbol (
tm
) becomes a link to that page.
-
The
\deprecated command
now accepts future versions.
-
QDoc macro arguments now accept formatting commands.
-
The
\compareswith
command now allows for brace-enclosed arguments.
-
The
-outputdir
command-line option is now relative to the current working directory. Also, the
nosubdirs
configuration variable no longer mangles what is in
outputdir
.
-
The unused and undocumented
clangdefines
configuration variable is removed.
-
QDoc no longer generates
.qhp.sha1
文件。
-
QDoc now generates unique references to entries in the table of contents.
-
When generating HTML output, QDoc now only decorates links to API entities with
translate="no"
.
-
Name collisions for multi-project documentation builds have been reduced. This may impact the generated file names in certain configurations.
-
CMake targets can now be specified with the new
\qtcmaketargetitem
命令。
-
Support for subscripted function arguments has been removed. This feature was undocumented, unused, and bug-ridden. Its removal saves the construction and attempted matching of regular expressions on every single documented function signature and
\a
command argument.
-
Links to function signatures are now more consistent in appearance.
-
QDoc now supports auto-generated values in QML documentation from C++ enums.
-
The
outputprefixes
and
outputsuffixes
configuration variables now apply to C++ type documentation as well as to QML type and module documentation. This can be convenient in multi-module documentation configurations where two or more modules define the same type names.
Arm-based Desktops
-
You can now build and develop Qt and Qt applications on Windows on Arm desktops.
-
You can now build and develop Qt and Qt applications on Linux on Arm desktops.
Windows
-
Changed the font system to use DirectWrite as the default backend. This enables some modern features which were not available with the legacy GDI backend. The previous backend is still available and can be enabled by passing
fontengine=gdi
as parameter to the QPA plugin.
macOS
-
Added support for macOS 15
-
Added support for safe area margins, both for the camera notch in full screen applications, and for windows where the contents extends into the titlebar.
-
Fixed flicker when resizing Qt Quick windows, by presenting Metal layer with transaction.
-
Enabled running animations when resizing Qt Quick windows.
-
Adopted new NSCursor API for window frame resize cursors
-
Implemented NSServicesMenuRequestor protocol for Services menu and Writing Tools support.
Linux 中的 Wayland 客户端
-
Added a new window decoration style that is used on GNOME and uses similar styling as GNOME.
-
Modal status of dialogs is now forwarded to the compositor via the new
xdg-dialog-v1 protocol
.
-
Showing a window will now also request activation from the compositor (except when
Qt::WA_ShowWithoutActivating
有设置)。
-
Added support to qtwaylandscanner to send null for null
QString
.
-
Added options
PUBLIC_CODE
and
PRIVATE_CODE
to
qt6_generate_wayland_protocol_client_sources
that control the options that are passed to
wayland-scanner
.
-
Implemented the screen capture feature using ScreenCast service via XDG Desktop Portal in Qt Multimedia.
Android
-
Bumped the minimum supported version to Android 9.
-
Added support for build.gradle namespace property.
-
Added a CMake property
QT_ANDROID_PACKAGE_NAME
to set the package name.
-
Updated Gradle to 8.10 and AGP to 8.6.0.
-
添加支持
building AAR library packages
.
-
Deprecated the native Android backend in Qt Multimedia.
-
When opening libraries with
QLibrary
, JNI_OnLoad is no longer called by default.
-
QtQuickView
and QML Embedding:
-
Added strong typing support for QtQuickView API.
-
Added API to manage QML content, under this Java classes under QtQuickView were moved to own classes. This includes:
-
QtQuickView.SignalListener to QtSignalListener.
-
QtQuickView.StatusChangeListener to QtQmlStatusChangeListener.
-
QtQuickView Status to QtQmlStatus.
-
Added Java classes QtAbstractItemModel, QtAbstractListModel, and QtModelIndex, that wraps
QAbstractItemModel
,
QAbstractListModel
,和
QModelIndex
,分别。
-
Added support for QML embedding from a Service.
iOS
-
Added support for iOS 18
-
Fixed wrongly reporting UIDevice.currentDevice.orientation via
QScreen::orientation
()
-
Improved accessibility integration.
visionOS
-
Added preliminary support for visionOS.
QNX
-
Added QNX 8.0 support as Technology Preview.
-
QNX 8.0 doesn't have multimedia support, use
-skip qtmultimedia
on configure.
VxWorks
-
Added VxWorks 24.03 support.
Boot to Qt
-
Support was added for Yocto 5.0 (Scarthgap).
-
The
目标硬件的支持级别
was updated with new supported boards for Tier 1:
-
The
目标硬件的支持级别
was updated with new supported boards for Tier 2:
-
NVIDIA Jetson AGX Orin Developer Kit (upgraded from Tier 3).
-
Raspberry Pi 4 64-bit (downgraded from Tier 1).
-
The
目标硬件的支持级别
was updated with new supported boards for Tier 3:
-
NXP i.MX95 (as experimental via
Qt Customer Portal
).
-
Toradex i.MX 95 Verdin Evaluation Kit (as experimental via
Qt Customer Portal
).
-
StarFive VisionFive 2.
-
ST STM32MP15 Evaluation (downgraded from Tier 2).
-
NXP i.MX 8MQuad Evaluation Kit (downgraded from Tier 2).
API 变化列表
These pages contain an overview of API changes in Qt 6.8: