Qt 6.x
The Qt SDK
Loading...
Searching...
No Matches
qt6-changes.qdoc
Go to the documentation of this file.
1// Copyright (C) 2020 The Qt Company Ltd.
2// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GFDL-1.3-no-invariants-only
3
4/*!
5 \page gui-changes-qt6.html
6 \title Changes to Qt GUI
7 \ingroup changes-qt-5-to-6
8 \brief Kernel, Text, Painting, and Utility classes are modified.
9
10 Qt 6 is a result of the conscious effort to make the framework more
11 efficient and easy to use.
12
13 We try to maintain binary and source compatibility for all the public
14 APIs in each release. But some changes were inevitable in an effort to
15 make Qt a better framework.
16
17 In this topic we summarize those changes in Qt GUI, and provide
18 guidance to handle them.
19
20 \section1 Kernel classes
21
22 \section2 The QBitmap class
23
24 Implicit construction of a QBitmap from a QPixmap is no longer supported.
25 The constructor and assignment operator have been made explicit and marked as
26 deprecated. Use the new static factory function \l{QBitmap::}{fromPixmap} instead.
27
28 \section2 The QCursor class
29
30 Implicit construction of a QCursor from a QPixmap is no longer supported, the
31 constructor has been made explicit.
32
33 \section2 The QKeyCombination class
34
35 QKeyCombination is a new class for storing a combination of a key with an
36 optional modifier. It should be used as a replacement for combining values from
37 the Qt::Key enum with a modifier in a type-safe way.
38
39 We recommend migrating code that currently uses operator+() to combine a key and
40 modifiers, as future C++ standards are likely to declare arithmetic operations
41 between unrelated enumeration types as illegal. Use operator|(), and change
42 APIs that expect an \c int to expect a QKeyCombination instead.
43
44 Existing APIs that expect an \c int for a key combination can be called using
45 QKeyCombination::toCombined().
46
47 \section1 Text classes
48
49 \section2 The QFontDatabase class
50
51 The QFontDatabase class has now only static member functions. The constructor
52 has been deprecated. Instead of e.g.
53
54 \code
55 const QStringList fontFamilies = QFontDatabase().families();
56 \endcode
57
58 use
59
60 \code
61 const QStringList fontFamilies = QFontDatabase::families();
62 \endcode
63
64 \section2 The QFont class
65
66 The numerical values of the QFont::Weight enumerator have been changed to
67 be in line with OpenType weight values. QFont::setWeight() expects an enum value
68 instead of an \c int, and code that calls the setter with an integer will fail to
69 compile. To continue to use old integer values, use QFont::setLegacyWeight().
70
71 \section1 Painting classes
72
73 See the porting guide for \l{Changes to Qt Print Support}{Qt Print Support} for
74 information about \l{QPagedPaintDevice} and other printing related classes.
75
76 \section1 Utility classes
77
78 \section2 QIntValidator and QDoubleValidator
79
80 The \l{QIntValidator::}{setRange()} method is no longer marked as virtual.
81
82 \section1 OpenGL classes
83
84 With the introduction of Qt RHI as the rendering foundation in Qt,
85 most classes prefixed by \c QOpenGL have been moved into the \l{Qt OpenGL}
86 module.
87
88 More details can be found in \l{Changes to Qt OpenGL}{the Qt OpenGL porting guide}.
89
90 One notable exception is the class \l QOpenGLContext, which still resides in
91 Qt GUI.
92
93 In addition, the class \l QOpenGLWidget has been moved to a new module, named
94 Qt OpenGL Widgets.
95
96 \section2 The QOpenGLContext class
97
98 The QOpenGLContext::versionFunctions() function is replaced by
99 QOpenGLVersionFunctionsFactory::get(). QOpenGLVersionFunctionsFactory is a public
100 class now, part of the \l{Qt OpenGL} module.
101
102 \section2 ANGLE
103
104 On Windows, ANGLE, a third-party OpenGL ES to Direct 3D translator, is no
105 longer included in Qt. This means Qt::AA_UseOpenGLES and the environment
106 variable \c{QT_OPENGL=angle} no longer have any effect.
107 In \l{Dynamically Loading OpenGL}{dynamic OpenGL builds} there is no automatic fallback to ANGLE in
108 case OpenGL proper fails to initialize. For QWindow or QWidget based
109 applications using OpenGL directly, for example via QOpenGLWidget, this means
110 that OpenGL proper is the only option at run time. However, the alternative of
111 using a pure software OpenGL implementation, such as Mesa llvmpipe that is
112 shipped with the pre-built Qt packages, is still available. For Qt Quick and Qt
113 Quick 3D applications, Qt 6 introduces support for Direct 3D 11, Vulkan, and
114 Metal, in addition to OpenGL. On Windows the default choice is Direct 3D,
115 therefore the removal of ANGLE is alleviated by having support for graphics
116 APIs other than OpenGL as well.
117*/