1// Copyright (C) 2020 The Qt Company Ltd.
2// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GFDL-1.3-no-invariants-only
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.
10 Qt 6 is a result of the conscious effort to make the framework more
11 efficient and easy to use.
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.
17 In this topic we summarize those changes in Qt GUI, and provide
18 guidance to handle them.
20 \section1 Kernel classes
22 \section2 The QBitmap class
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.
28 \section2 The QCursor class
30 Implicit construction of a QCursor from a QPixmap is no longer supported, the
31 constructor has been made explicit.
33 \section2 The QKeyCombination class
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.
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.
44 Existing APIs that expect an \c int for a key combination can be called using
45 QKeyCombination::toCombined().
47 \section1 Text classes
49 \section2 The QFontDatabase class
51 The QFontDatabase class has now only static member functions. The constructor
52 has been deprecated. Instead of e.g.
55 const QStringList fontFamilies = QFontDatabase().families();
61 const QStringList fontFamilies = QFontDatabase::families();
64 \section2 The QFont class
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().
71 \section1 Painting classes
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.
76 \section1 Utility classes
78 \section2 QIntValidator and QDoubleValidator
80 The \l{QIntValidator::}{setRange()} method is no longer marked as virtual.
82 \section1 OpenGL classes
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}
88 More details can be found in \l{Changes to Qt OpenGL}{the Qt OpenGL porting guide}.
90 One notable exception is the class \l QOpenGLContext, which still resides in
93 In addition, the class \l QOpenGLWidget has been moved to a new module, named
96 \section2 The QOpenGLContext class
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.
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.