1// Copyright (C) 2021 The Qt Company Ltd.
2// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GFDL-1.3-no-invariants-only
5 \page widgets-changes-qt6.html
6 \title Changes to Qt Widgets
7 \ingroup changes-qt-5-to-6
8 \brief Changes in Kernel classes, Widgets, ItemViews, and Utility Classes.
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 Widgets, and provide
18 guidance to handle them.
20 \section1 Kernel classes
22 \section2 The QWidget class
24 The virtual QWidget::enterEvent() handler now receives a QEnterEvent*
25 parameter which has information about the pointer position, rather than
28 \section2 QDesktopWidget and QApplication::desktop()
30 QDesktopWidget was already deprecated in Qt 5, and has been removed in
31 Qt 6, together with QApplication::desktop().
33 QScreen provides equivalent functionality to query for information about
34 available screens, screen that form a virtual desktop, and screen
37 Use QWidget::setScreen() to create a QWidget on a specific display;
38 note that this does not move a widget to a screen in a virtual desktop
41 \section2 QAction, QActionGroup
43 These classes have been moved into the QtGui module. Member functions that
44 depend on types defined in QtWidgets (such as QAction::menu() and
45 QAction::setMenu()) are implemented as templates that will be instantiated
50 \section2 The QAbstractButton class
52 The default timeout parameter for QAbstractButton::animateClick() is
53 removed to allow modern connection syntax without the need for qOverload.
55 \section2 The QComboBox class
57 The QComboBox::setModel() function is now virtual.
59 \section2 The QDateTimeEdit class
61 When QDateTimeEdit::setDateTime() is called with a date-time whose
62 time-spec doesn't match that of the QDateTimeEdit instance, the
63 date-time is converted to the time-spec of the QDateTimeEdit. This
64 gives a date-time that describes the same instant in time, but
65 does so in the same terms as the QDateTimeEdit uses. Previously,
66 the date and time from the passed date-time were combined with the
67 time-spec of the widget, ignoring the time-spec of the date-time;
68 this could describe a different point in time than the one
69 described by the date-time passed.
73 \section2 The QAbstractItemView class
75 The virtual viewOptions() method that previously returned a QStyleOptionViewItem
76 object has been renamed to initViewItemOption, and initializes a
77 QStyleOptionViewItem object that's passed in through a pointer.
79 \section1 Styling Classes and related APIs
81 All versioned QStyleOption subclasses are consolidated, and the version
82 numbers are reset to 1.
84 The various initStyleOption() methods in widget classes are now virtual.
86 \section2 Style sheet changes
88 Styling a widget by its property in Qt 5 vs Qt 6 is different, especially if the
89 property is an enum. In Qt 5, the selector value for such a property is the integer
90 equivalent of the enum value, while in Qt 6 the string value is used. The following
91 example demonstrates this difference:
95 QToolButton[popupMode="1"] {
102 QToolButton[popupMode=MenuButtonPopup] {
107 \section1 Utility Classes
109 \section2 QUndoCommand, QUndoStack, and QUndoGroup
111 The widget independent classes of the Undo/Redo framework have been moved
112 into the QtGui module.