From f2f1a93c58b6cb88f3cd0655e95ccd5ad99286d0 Mon Sep 17 00:00:00 2001 From: Christian Ehrlicher Date: Wed, 7 Aug 2019 21:36:41 +0200 Subject: QToolBarLayout: fix position calculation Fix a bug introduced in d493f676a38f000dd9c22dee6eea2b5ae4291e0a while calculating the size / position of the layout item. Fixes: QTBUG-77115 Change-Id: I20ad1685659da7225009734e25287e590367aa9e Reviewed-by: Richard Moe Gustavsen --- src/widgets/widgets/qtoolbarlayout.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/widgets') diff --git a/src/widgets/widgets/qtoolbarlayout.cpp b/src/widgets/widgets/qtoolbarlayout.cpp index d50e19a5ed..961a261e8f 100644 --- a/src/widgets/widgets/qtoolbarlayout.cpp +++ b/src/widgets/widgets/qtoolbarlayout.cpp @@ -533,7 +533,7 @@ bool QToolBarLayout::layoutActions(const QSize &size) if (expanded) rperp(o, size) = rowHeight; else - rperp(o, size) = perp(o, rect.size()) - perp(o, QSize(margins.top(), margins.left())); + rperp(o, size) = perp(o, rect.size()) - perp(o, margins); QRect r(pos, size); if (o == Qt::Horizontal) -- cgit v1.2.3 From 43a1db6855217a67d771ad031feded112e1447c8 Mon Sep 17 00:00:00 2001 From: Volker Hilsheimer Date: Fri, 30 Aug 2019 11:23:24 +0200 Subject: Fix the documentation - QSystemTrayIcon::messageClicked works on macOS MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Trivially reproduced by the systray example. Task-number: QTBUG-77150 Change-Id: I888db728741c35e8b0378c38c8747ad163cad47d Reviewed-by: Tor Arne Vestbø --- src/widgets/util/qsystemtrayicon.cpp | 2 -- 1 file changed, 2 deletions(-) (limited to 'src/widgets') diff --git a/src/widgets/util/qsystemtrayicon.cpp b/src/widgets/util/qsystemtrayicon.cpp index a38a50d3df..a02645b1df 100644 --- a/src/widgets/util/qsystemtrayicon.cpp +++ b/src/widgets/util/qsystemtrayicon.cpp @@ -367,8 +367,6 @@ bool QSystemTrayIcon::event(QEvent *e) This signal is emitted when the message displayed using showMessage() was clicked by the user. - Currently this signal is not sent on \macos. - \note We follow Microsoft Windows behavior, so the signal is also emitted when the user clicks on a tray icon with a balloon message displayed. -- cgit v1.2.3 From f00e32665679ee225384743849156fbb3bd5eb64 Mon Sep 17 00:00:00 2001 From: Friedemann Kleint Date: Tue, 13 Aug 2019 16:37:17 +0200 Subject: Fix some qdoc warnings in 5.14 Mark QCalendarBackend as internal since it is in a private header and fix some issues in the QCalendar related classes. src/corelib/time/qcalendar.cpp:201: (qdoc) warning: clang found diagnostics parsing \fn int QCalendarBackend::daysInMonth(int month, int year) const error: incomplete type 'QCalendarBackend' named in nested name specifier (repeats) src/corelib/time/qdatetime.cpp:1426: (qdoc) warning: Unknown command '\override' (repeats) src/corelib/time/qcalendar.cpp:642: (qdoc) warning: Undocumented enum item 'Last' in QCalendar::System src/corelib/time/qcalendar.cpp:642: (qdoc) warning: Undocumented enum item 'User' in QCalendar::System src/corelib/time/qcalendar.cpp:744: (qdoc) warning: Undocumented parameter 'year' in QCalendar::isLeapYear() src/corelib/time/qcalendar.cpp:923: (qdoc) warning: Can't link to 'dateTimeString()' (repeats) src/corelib/time/qcalendar.cpp:893: (qdoc) warning: No such parameter 'year' in QCalendar::partsFromDate() src/corelib/time/qcalendar.cpp:893: (qdoc) warning: No such parameter 'month' in QCalendar::partsFromDate() src/corelib/time/qcalendar.cpp:893: (qdoc) warning: No such parameter 'day' in QCalendar::partsFromDate() src/corelib/time/qdatetime.cpp:1425: (qdoc) warning: Undocumented parameter 'nmonths' in QDate::addMonths() src/corelib/time/qdatetime.cpp:1467: (qdoc) warning: Undocumented parameter 'nyears' in QDate::addYears() src/corelib/statemachine/qstatemachine.cpp:2522: (qdoc) warning: Undocumented enum item 'StateMachineChildModeSetToParallelError' in QStateMachine::Error src/corelib/kernel/qtimer.cpp:602: (qdoc) warning: Undocumented parameter 'connectionType' in QTimer::callOnTimeout() src/corelib/time/qcalendar.cpp:159: (qdoc) warning: Undocumented parameter 'name' in QCalendarBackend::QCalendarBackend() src/corelib/time/qcalendar.cpp:159: (qdoc) warning: Undocumented parameter 'id' in QCalendarBackend::QCalendarBackend() src/corelib/time/qcalendar.cpp:529: (qdoc) warning: Can't link to 'registerCalendar()' src/corelib/time/qcalendar.cpp:529: (qdoc) warning: Can't link to 'fromName()' src/corelib/time/qcalendar.cpp:178: (qdoc) warning: Can't link to 'QCalendar::fromEnum()' src/corelib/time/qcalendar.cpp:405: (qdoc) warning: Undocumented parameter 'jd' in QCalendarBackend::dayOfWeek() src/corelib/time/qcalendar.cpp:405: (qdoc) warning: Can't link to 'weekDayName()' src/corelib/time/qcalendar.cpp:405: (qdoc) warning: Can't link to 'standaloneWeekDayName()' src/corelib/time/qcalendar.cpp:268: (qdoc) warning: Can't link to 'daysInMonth()' src/corelib/time/qcalendar.cpp:268: (qdoc) warning: Can't link to 'isLeapYear()' src/corelib/time/qcalendar.cpp:295: (qdoc) warning: Can't link to 'daysInMonth()' src/corelib/time/qcalendar.cpp:313: (qdoc) warning: Can't link to 'isLuniSolar()' src/corelib/time/qcalendar.cpp:313: (qdoc) warning: Can't link to 'isSolar()' src/corelib/time/qcalendar.cpp:313: (qdoc) warning: Can't link to 'isLunar()' src/corelib/time/qcalendar.cpp:340: (qdoc) warning: Can't link to 'daysInMonth()' src/corelib/time/qcalendar.cpp:357: (qdoc) warning: Can't link to 'daysInMonth()' src/corelib/time/qcalendar.cpp:544: (qdoc) warning: Can't link to 'fromName()' Change-Id: Ia2fabefb917f8e4cfa361044d9b754717276f4aa Reviewed-by: Edward Welbourne Reviewed-by: Paul Wicking --- src/widgets/kernel/qwidgetrepaintmanager.cpp | 2 ++ 1 file changed, 2 insertions(+) (limited to 'src/widgets') diff --git a/src/widgets/kernel/qwidgetrepaintmanager.cpp b/src/widgets/kernel/qwidgetrepaintmanager.cpp index 4eb298e108..c3211e275f 100644 --- a/src/widgets/kernel/qwidgetrepaintmanager.cpp +++ b/src/widgets/kernel/qwidgetrepaintmanager.cpp @@ -147,6 +147,7 @@ QWidgetRepaintManager::~QWidgetRepaintManager() } /*! + \internal Invalidates the \a r (in widget's coordinates) of the backing store, i.e. all widgets intersecting with the region will be repainted when the backing store is synced. @@ -193,6 +194,7 @@ static inline QRect widgetRectFor(QWidget *, const QRect &r) { return r; } static inline QRect widgetRectFor(QWidget *widget, const QRegion &) { return widget->rect(); } /*! + \internal Marks the region of the widget as dirty (if not already marked as dirty) and posts an UpdateRequest event to the top-level widget (if not already posted). -- cgit v1.2.3 From 46ec24d2b9a0fb1d59955f11dab0ead05dd017f9 Mon Sep 17 00:00:00 2001 From: Edward Welbourne Date: Tue, 3 Sep 2019 15:18:14 +0200 Subject: Rename calendar methods from m{in,ax} to m{in,ax}imum Words should not be abbreviated. Split a long line and reflowed some comments in the process. Fixes: QTBUG-78008 Change-Id: I52d75409f02e2cecbed3e94d424617ad594c275b Reviewed-by: Friedemann Kleint --- src/widgets/widgets/qcalendarwidget.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src/widgets') diff --git a/src/widgets/widgets/qcalendarwidget.cpp b/src/widgets/widgets/qcalendarwidget.cpp index ec19b64d4a..cc0c51b237 100644 --- a/src/widgets/widgets/qcalendarwidget.cpp +++ b/src/widgets/widgets/qcalendarwidget.cpp @@ -2413,7 +2413,7 @@ void QCalendarWidget::showNextMonth() Q_D(const QCalendarWidget); int year = yearShown(); int month = monthShown(); - if (month == d->m_model->m_calendar.maxMonthsInYear()) { + if (month == d->m_model->m_calendar.maximumMonthsInYear()) { ++year; month = 1; } else { @@ -2437,7 +2437,7 @@ void QCalendarWidget::showPreviousMonth() int month = monthShown(); if (month == 1) { --year; - month = d->m_model->m_calendar.maxMonthsInYear(); + month = d->m_model->m_calendar.maximumMonthsInYear(); } else { --month; } -- cgit v1.2.3 From e82a1d6b2998b30fc100c4ebf9b98ee18dd3c374 Mon Sep 17 00:00:00 2001 From: Friedemann Kleint Date: Fri, 16 Aug 2019 11:30:58 +0200 Subject: Deprecate QDirModel Deprecate the constructors, add guards. Use a QStandardItemModel in tst_QCompleter::setters() instead. Task-number: QTBUG-69410 Change-Id: If77298982bb3d0b5321ae1271fab3f33b196101d Reviewed-by: Qt CI Bot Reviewed-by: Richard Moe Gustavsen --- src/widgets/itemviews/qdirmodel.cpp | 4 ++++ src/widgets/itemviews/qdirmodel.h | 11 ++++++++--- src/widgets/util/qcompleter.cpp | 10 +++++----- 3 files changed, 17 insertions(+), 8 deletions(-) (limited to 'src/widgets') diff --git a/src/widgets/itemviews/qdirmodel.cpp b/src/widgets/itemviews/qdirmodel.cpp index 13a1bbd8eb..ba7ee15314 100644 --- a/src/widgets/itemviews/qdirmodel.cpp +++ b/src/widgets/itemviews/qdirmodel.cpp @@ -39,6 +39,8 @@ #include "qdirmodel.h" +#if QT_DEPRECATED_SINCE(5, 15) + #include #include #include @@ -1372,3 +1374,5 @@ QFileInfo QDirModelPrivate::resolvedInfo(QFileInfo info) QT_END_NAMESPACE #include "moc_qdirmodel.cpp" + +#endif // QT_DEPRECATED_SINCE(5, 15) diff --git a/src/widgets/itemviews/qdirmodel.h b/src/widgets/itemviews/qdirmodel.h index ab91bbd763..665a622dbe 100644 --- a/src/widgets/itemviews/qdirmodel.h +++ b/src/widgets/itemviews/qdirmodel.h @@ -45,6 +45,8 @@ #include #include +#if QT_DEPRECATED_SINCE(5, 15) + QT_REQUIRE_CONFIG(dirmodel); QT_BEGIN_NAMESPACE @@ -65,9 +67,10 @@ public: FileNameRole }; - QDirModel(const QStringList &nameFilters, QDir::Filters filters, - QDir::SortFlags sort, QObject *parent = nullptr); - explicit QDirModel(QObject *parent = nullptr); + QT_DEPRECATED_VERSION_X_5_15("Use QFileSystemModel") QDirModel(const QStringList &nameFilters, + QDir::Filters filters, QDir::SortFlags sort, + QObject *parent = nullptr); + QT_DEPRECATED_VERSION_X_5_15("Use QFileSystemModel") explicit QDirModel(QObject *parent = nullptr); ~QDirModel(); QModelIndex index(int row, int column, const QModelIndex &parent = QModelIndex()) const override; @@ -144,4 +147,6 @@ private: QT_END_NAMESPACE +#endif // QT_DEPRECATED_SINCE(5, 15) + #endif // QDIRMODEL_H diff --git a/src/widgets/util/qcompleter.cpp b/src/widgets/util/qcompleter.cpp index 7b69eff30c..3c0271e7c2 100644 --- a/src/widgets/util/qcompleter.cpp +++ b/src/widgets/util/qcompleter.cpp @@ -473,7 +473,7 @@ QMatchData QCompletionEngine::filterHistory() if (curParts.count() <= 1 || c->proxy->showAll || !source) return QMatchData(); -#if QT_CONFIG(dirmodel) +#if QT_CONFIG(dirmodel) && QT_DEPRECATED_SINCE(5, 15) const bool isDirModel = (qobject_cast(source) != nullptr); #else const bool isDirModel = false; @@ -903,7 +903,7 @@ void QCompleterPrivate::_q_complete(QModelIndex index, bool highlighted) QModelIndex si = proxy->mapToSource(index); si = si.sibling(si.row(), column); // for clicked() completion = q->pathFromIndex(si); -#if QT_CONFIG(dirmodel) +#if QT_CONFIG(dirmodel) && QT_DEPRECATED_SINCE(5, 15) // add a trailing separator in inline if (mode == QCompleter::InlineCompletion) { if (qobject_cast(proxy->sourceModel()) && QFileInfo(completion).isDir()) @@ -1125,7 +1125,7 @@ void QCompleter::setModel(QAbstractItemModel *model) setPopup(d->popup); // set the model and make new connections if (oldModel && oldModel->QObject::parent() == this) delete oldModel; -#if QT_CONFIG(dirmodel) +#if QT_CONFIG(dirmodel) && QT_DEPRECATED_SINCE(5, 15) if (qobject_cast(model)) { #if defined(Q_OS_WIN) setCaseSensitivity(Qt::CaseInsensitive); @@ -1846,7 +1846,7 @@ QString QCompleter::pathFromIndex(const QModelIndex& index) const return QString(); bool isDirModel = false; bool isFsModel = false; -#if QT_CONFIG(dirmodel) +#if QT_CONFIG(dirmodel) && QT_DEPRECATED_SINCE(5, 15) isDirModel = qobject_cast(d->proxy->sourceModel()) != nullptr; #endif #if QT_CONFIG(filesystemmodel) @@ -1895,7 +1895,7 @@ QStringList QCompleter::splitPath(const QString& path) const { bool isDirModel = false; bool isFsModel = false; -#if QT_CONFIG(dirmodel) +#if QT_CONFIG(dirmodel) && QT_DEPRECATED_SINCE(5, 15) Q_D(const QCompleter); isDirModel = qobject_cast(d->proxy->sourceModel()) != nullptr; #endif -- cgit v1.2.3 From 42011c03613b38d2bf9c7770edf1392c5f5598f2 Mon Sep 17 00:00:00 2001 From: Christian Ehrlicher Date: Mon, 26 Aug 2019 19:38:39 +0200 Subject: QGraphicsView: mark obsolete flag DontClipPainter as deprecated The enum OptimizationFlag::DontClipPainter is deprecated and not used in the code since Qt4 times. Therefore also mark it as deprecated so it can be removed with Qt6 Change-Id: I318a55cf42e7a233d13d4ec0144e1977251f5c92 Reviewed-by: Oliver Wolff --- src/widgets/graphicsview/qgraphicsview.h | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'src/widgets') diff --git a/src/widgets/graphicsview/qgraphicsview.h b/src/widgets/graphicsview/qgraphicsview.h index e02fba69c9..1389796c3f 100644 --- a/src/widgets/graphicsview/qgraphicsview.h +++ b/src/widgets/graphicsview/qgraphicsview.h @@ -107,7 +107,9 @@ public: Q_ENUM(ViewportUpdateMode) enum OptimizationFlag { - DontClipPainter = 0x1, // obsolete +#if QT_DEPRECATED_SINCE(5, 14) + DontClipPainter Q_DECL_ENUMERATOR_DEPRECATED_X("This flag is unused") = 0x1, // obsolete +#endif DontSavePainterState = 0x2, DontAdjustForAntialiasing = 0x4, IndirectPainting = 0x8 -- cgit v1.2.3 From a42a4513398a159e4f6749fbcb1309c4a42b4841 Mon Sep 17 00:00:00 2001 From: Christian Ehrlicher Date: Fri, 30 Aug 2019 22:06:17 +0200 Subject: QShortcut: call base class implementation in event() QShortcut::event() did not call the base class implementation QObject::event() which caused that e.g. QEvent::DeferredDelete was not handled. Fix it by calling QObject::event() when the event was not handled. Fixes: QTBUG-66809 Change-Id: Ideebc980bc658f8f2b9ec4417e738bccda5eeab5 Reviewed-by: Volker Hilsheimer --- src/widgets/kernel/qshortcut.cpp | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) (limited to 'src/widgets') diff --git a/src/widgets/kernel/qshortcut.cpp b/src/widgets/kernel/qshortcut.cpp index b7857e2b74..db06dce042 100644 --- a/src/widgets/kernel/qshortcut.cpp +++ b/src/widgets/kernel/qshortcut.cpp @@ -665,24 +665,22 @@ int QShortcut::id() const bool QShortcut::event(QEvent *e) { Q_D(QShortcut); - bool handled = false; if (d->sc_enabled && e->type() == QEvent::Shortcut) { QShortcutEvent *se = static_cast(e); if (se->shortcutId() == d->sc_id && se->key() == d->sc_sequence){ #if QT_CONFIG(whatsthis) if (QWhatsThis::inWhatsThisMode()) { QWhatsThis::showText(QCursor::pos(), d->sc_whatsthis); - handled = true; } else #endif if (se->isAmbiguous()) emit activatedAmbiguously(); else emit activated(); - handled = true; + return true; } } - return handled; + return QObject::event(e); } #endif // QT_NO_SHORTCUT -- cgit v1.2.3 From 5f570aa64d13bf21677990f3e0deb8c4bb5f7b5d Mon Sep 17 00:00:00 2001 From: Christian Ehrlicher Date: Sun, 8 Sep 2019 21:08:35 +0200 Subject: QComboBox: add documentation for textHighlighted/textActivated The documentation for textHighlighted/textActivated was not added within bdf1c4f671c706832cea84269e91995e85eb9f07 so add it now. Change-Id: Ifa7ad72af4490d4ce1d6de00d0963c0e76013f42 Reviewed-by: Friedemann Kleint --- src/widgets/widgets/qcombobox.cpp | 21 +++++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) (limited to 'src/widgets') diff --git a/src/widgets/widgets/qcombobox.cpp b/src/widgets/widgets/qcombobox.cpp index e73c63f657..a53c278aea 100644 --- a/src/widgets/widgets/qcombobox.cpp +++ b/src/widgets/widgets/qcombobox.cpp @@ -862,6 +862,16 @@ QStyleOptionComboBox QComboBoxPrivateContainer::comboStyleOption() const when the choice is not changed. If you need to know when the choice actually changes, use signal currentIndexChanged(). + \obsolete Use QComboBox::textActivated() instead +*/ +/*! + \fn void QComboBox::textActivated(const QString &text) + \since 5.14 + + This signal is sent when the user chooses an item in the combobox. + The item's \a text is passed. Note that this signal is sent even + when the choice is not changed. If you need to know when the + choice actually changes, use signal currentIndexChanged(). */ /*! @@ -876,6 +886,15 @@ QStyleOptionComboBox QComboBoxPrivateContainer::comboStyleOption() const This signal is sent when an item in the combobox popup list is highlighted by the user. The item's \a text is passed. + + \obsolete Use textHighlighted() instead +*/ +/*! + \fn void QComboBox::textHighlighted(const QString &text) + \since 5.14 + + This signal is sent when an item in the combobox popup list is + highlighted by the user. The item's \a text is passed. */ /*! @@ -888,7 +907,6 @@ QStyleOptionComboBox QComboBoxPrivateContainer::comboStyleOption() const currentIndex was reset. */ -#if QT_DEPRECATED_SINCE(5, 13) /*! \fn void QComboBox::currentIndexChanged(const QString &text) \since 4.1 @@ -897,7 +915,6 @@ QStyleOptionComboBox QComboBoxPrivateContainer::comboStyleOption() const changes either through user interaction or programmatically. The item's \a text is passed. */ -#endif /*! \fn void QComboBox::currentTextChanged(const QString &text) -- cgit v1.2.3 From 648dac1ceb40a346adf2081997f5c6166c3ad503 Mon Sep 17 00:00:00 2001 From: Shawn Rutledge Date: Thu, 5 Sep 2019 17:01:23 +0200 Subject: QMenu::popup(): don't change the menu's screen if called from exec() Since b3fc5e1ea3eb4fe838ac716aaca4efaa5de5a814, topData()->initialScreenIndex has always been short-lived: it only remembers the screen in case the widget parent is a QDesktopScreenWidget (gotten from QDesktopWidget::screen()), only until the window is created. Then it is reset. In the case of exec() we need to avoid calling setScreen() twice, because that would set the screen once, then forget which screen it was supposed to be on, then set the screen again when exec() calls popup(). This is achieved by using the stored eventLoop pointer to detect that popup() is being called from exec(), and avoid calling setScreen() a second time in popup(), because exec() already needed to call createWinId() before it created the event loop. Amends 82da8306bc1313b85632eee0faf858239261a092 Task-number: QTBUG-76162 Change-Id: I70da517b9d530630e59d103cb2a1ce11c897b2c8 Reviewed-by: Friedemann Kleint Reviewed-by: Joni Poikelin --- src/widgets/widgets/qmenu.cpp | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) (limited to 'src/widgets') diff --git a/src/widgets/widgets/qmenu.cpp b/src/widgets/widgets/qmenu.cpp index e38490dabd..51b458f03a 100644 --- a/src/widgets/widgets/qmenu.cpp +++ b/src/widgets/widgets/qmenu.cpp @@ -2332,14 +2332,17 @@ void QMenu::popup(const QPoint &p, QAction *atAction) // However if the QMenu was constructed with a QDesktopScreenWidget as its parent, // then initialScreenIndex was set, so we should respect that for the lifetime of this menu. // Use d->popupScreen to remember, because initialScreenIndex will be reset after the first showing. - const int screenIndex = d->topData()->initialScreenIndex; - if (screenIndex >= 0) - d->popupScreen = screenIndex; - if (auto s = QGuiApplication::screens().value(d->popupScreen)) { - if (d->setScreen(s)) + // However if eventLoop exists, then exec() already did this by calling createWinId(); so leave it alone. (QTBUG-76162) + if (!d->eventLoop) { + const int screenIndex = d->topData()->initialScreenIndex; + if (screenIndex >= 0) + d->popupScreen = screenIndex; + if (auto s = QGuiApplication::screens().value(d->popupScreen)) { + if (d->setScreen(s)) + d->itemsDirty = true; + } else if (d->setScreenForPoint(p)) { d->itemsDirty = true; - } else if (d->setScreenForPoint(p)) { - d->itemsDirty = true; + } } const bool contextMenu = d->isContextMenu(); -- cgit v1.2.3 From 49362d064fffe350600f5324fb510b381578d04a Mon Sep 17 00:00:00 2001 From: Sona Kurazyan Date: Wed, 4 Sep 2019 17:26:33 +0200 Subject: Add a QSplashScreen constructor taking a QScreen MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The constructor taking a QWidget is needed for specifying the screen where the splash screen should be displayed. Add a new constructor for specifying the target screen for the splash screen directly, instead of "extracting" the screen information from a widget. This removes the need for using the deprecated QDesktopWidget. Deprecate the constructor taking a QWidget. Task-number: QTBUG-76491 Change-Id: I1dde242ff5f7b53e52af308bb685f492d6266d33 Reviewed-by: Tor Arne Vestbø --- src/widgets/doc/snippets/qsplashscreen/main.cpp | 7 +++++ src/widgets/widgets/qsplashscreen.cpp | 38 +++++++++++++++++++++++-- src/widgets/widgets/qsplashscreen.h | 4 +++ 3 files changed, 46 insertions(+), 3 deletions(-) (limited to 'src/widgets') diff --git a/src/widgets/doc/snippets/qsplashscreen/main.cpp b/src/widgets/doc/snippets/qsplashscreen/main.cpp index 843932ca83..2512035879 100644 --- a/src/widgets/doc/snippets/qsplashscreen/main.cpp +++ b/src/widgets/doc/snippets/qsplashscreen/main.cpp @@ -71,3 +71,10 @@ int main(int argc, char *argv[]) return app.exec(); } //! [1] + +//! [2] +QScreen *screen = QGuiApplication::screens().at(1); +QPixmap pixmap(":/splash.png"); +QSplashScreen splash(screen, pixmap); +splash.show(); +//! [2] diff --git a/src/widgets/widgets/qsplashscreen.cpp b/src/widgets/widgets/qsplashscreen.cpp index e39ef6d1cd..b7c3426e08 100644 --- a/src/widgets/widgets/qsplashscreen.cpp +++ b/src/widgets/widgets/qsplashscreen.cpp @@ -123,6 +123,11 @@ public: wish to do your own drawing you can get a pointer to the pixmap used in the splash screen with pixmap(). Alternatively, you can subclass QSplashScreen and reimplement drawContents(). + + In case of having multiple screens, it is also possible to show the + splash screen on a different screen than the primary one. For example: + + \snippet qsplashscreen/main.cpp 2 */ /*! @@ -139,6 +144,23 @@ QSplashScreen::QSplashScreen(const QPixmap &pixmap, Qt::WindowFlags f) /*! \overload + \since 5.15 + + This function allows you to specify the screen for your splashscreen. The + typical use for this constructor is if you have multiple screens and + prefer to have the splash screen on a different screen than your primary + one. In that case pass the proper \a screen. +*/ +QSplashScreen::QSplashScreen(QScreen *screen, const QPixmap &pixmap, Qt::WindowFlags f) + : QWidget(*(new QSplashScreenPrivate()), nullptr, Qt::SplashScreen | Qt::FramelessWindowHint | f) +{ + d_func()->setPixmap(pixmap, screen); +} + +#if QT_DEPRECATED_SINCE(5, 15) +/*! + \overload + \obsolete This function allows you to specify a parent for your splashscreen. The typical use for this constructor is if you have a multiple screens and @@ -152,6 +174,7 @@ QSplashScreen::QSplashScreen(QWidget *parent, const QPixmap &pixmap, Qt::WindowF // is still 0 here due to QWidget's special handling. d_func()->setPixmap(pixmap, QSplashScreenPrivate::screenFor(parent)); } +#endif /*! Destructor. @@ -286,26 +309,35 @@ void QSplashScreen::setPixmap(const QPixmap &pixmap) } // In setPixmap(), resize and try to position on a screen according to: -// 1) If a QDesktopScreenWidget is found in the parent hierarchy, use that (see docs on +// 1) If the screen for the given widget is available, use that +// 2) If a QDesktopScreenWidget is found in the parent hierarchy, use that (see docs on // QSplashScreen(QWidget *, QPixmap). -// 2) If a widget with associated QWindow is found, use that -// 3) When nothing can be found, try to center it over the cursor +// 3) If a widget with associated QWindow is found, use that +// 4) When nothing can be found, try to center it over the cursor +#if QT_DEPRECATED_SINCE(5, 15) static inline int screenNumberOf(const QDesktopScreenWidget *dsw) { auto desktopWidgetPrivate = static_cast(qt_widget_private(QApplication::desktop())); return desktopWidgetPrivate->screens.indexOf(const_cast(dsw)); } +#endif const QScreen *QSplashScreenPrivate::screenFor(const QWidget *w) { + if (w && w->screen()) + return w->screen(); + for (const QWidget *p = w; p !=nullptr ; p = p->parentWidget()) { +#if QT_DEPRECATED_SINCE(5, 15) if (auto dsw = qobject_cast(p)) return QGuiApplication::screens().value(screenNumberOf(dsw)); +#endif if (QWindow *window = p->windowHandle()) return window->screen(); } + #if QT_CONFIG(cursor) // Note: We could rely on QPlatformWindow::initialGeometry() to center it // over the cursor, but not all platforms (namely Android) use that. diff --git a/src/widgets/widgets/qsplashscreen.h b/src/widgets/widgets/qsplashscreen.h index 8bdf4e7749..1877493fcf 100644 --- a/src/widgets/widgets/qsplashscreen.h +++ b/src/widgets/widgets/qsplashscreen.h @@ -55,7 +55,11 @@ class Q_WIDGETS_EXPORT QSplashScreen : public QWidget Q_OBJECT public: explicit QSplashScreen(const QPixmap &pixmap = QPixmap(), Qt::WindowFlags f = Qt::WindowFlags()); + QSplashScreen(QScreen *screen, const QPixmap &pixmap = QPixmap(), Qt::WindowFlags f = Qt::WindowFlags()); +#if QT_DEPRECATED_SINCE(5, 15) + QT_DEPRECATED_VERSION_X_5_15("Use the constructor taking a QScreen *") QSplashScreen(QWidget *parent, const QPixmap &pixmap = QPixmap(), Qt::WindowFlags f = Qt::WindowFlags()); +#endif virtual ~QSplashScreen(); void setPixmap(const QPixmap &pixmap); -- cgit v1.2.3 From c0b3c06a7d4f6a2f90742e8dc81c898082a70416 Mon Sep 17 00:00:00 2001 From: Friedemann Kleint Date: Thu, 5 Sep 2019 09:52:05 +0200 Subject: QFileDialog: Fix volume name display on Windows MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The volume names displayed did not match those of Windows Explorer; for example "New Volume (X:)" would be displayed for mapped network drives. Replace GetVolumeInformation() and manual formatting by the normal display name of IShellItem. Fixes: QTBUG-78043 Change-Id: Ia742b7733e8ddc31e9506f15d90d065b985a111d Reviewed-by: André de la Rocha --- src/widgets/dialogs/qfilesystemmodel.cpp | 39 +++++++++++++++++++++++--------- 1 file changed, 28 insertions(+), 11 deletions(-) (limited to 'src/widgets') diff --git a/src/widgets/dialogs/qfilesystemmodel.cpp b/src/widgets/dialogs/qfilesystemmodel.cpp index e9e49e0c33..a04189513a 100644 --- a/src/widgets/dialogs/qfilesystemmodel.cpp +++ b/src/widgets/dialogs/qfilesystemmodel.cpp @@ -57,6 +57,9 @@ #ifdef Q_OS_WIN # include # include +# ifndef Q_OS_WINRT +# include +# endif #endif QT_BEGIN_NAMESPACE @@ -837,8 +840,8 @@ QString QFileSystemModelPrivate::displayName(const QModelIndex &index) const { #if defined(Q_OS_WIN) QFileSystemNode *dirNode = node(index); - if (!dirNode->volumeName.isNull()) - return dirNode->volumeName + QLatin1String(" (") + name(index) + QLatin1Char(')'); + if (!dirNode->volumeName.isEmpty()) + return dirNode->volumeName; #endif return name(index); } @@ -1773,6 +1776,27 @@ void QFileSystemModelPrivate::_q_directoryChanged(const QString &directory, cons removeNode(parentNode, toRemove[i]); } +#if defined(Q_OS_WIN) && !defined(Q_OS_WINRT) +static QString volumeName(const QString &path) +{ + IShellItem *item = nullptr; + const QString native = QDir::toNativeSeparators(path); + HRESULT hr = SHCreateItemFromParsingName(reinterpret_cast(native.utf16()), + nullptr, IID_IShellItem, + reinterpret_cast(&item)); + if (FAILED(hr)) + return QString(); + LPWSTR name = nullptr; + hr = item->GetDisplayName(SIGDN_NORMALDISPLAY, &name); + if (FAILED(hr)) + return QString(); + QString result = QString::fromWCharArray(name); + CoTaskMemFree(name); + item->Release(); + return result; +} +#endif // Q_OS_WIN && !Q_OS_WINRT + /*! \internal @@ -1791,15 +1815,8 @@ QFileSystemModelPrivate::QFileSystemNode* QFileSystemModelPrivate::addNode(QFile #endif #if defined(Q_OS_WIN) && !defined(Q_OS_WINRT) //The parentNode is "" so we are listing the drives - if (parentNode->fileName.isEmpty()) { - wchar_t name[MAX_PATH + 1]; - //GetVolumeInformation requires to add trailing backslash - const QString nodeName = fileName + QLatin1String("\\"); - BOOL success = ::GetVolumeInformation((wchar_t *)(nodeName.utf16()), - name, MAX_PATH + 1, NULL, 0, NULL, NULL, 0); - if (success && name[0]) - node->volumeName = QString::fromWCharArray(name); - } + if (parentNode->fileName.isEmpty()) + node->volumeName = volumeName(fileName); #endif Q_ASSERT(!parentNode->children.contains(fileName)); parentNode->children.insert(fileName, node); -- cgit v1.2.3 From 66a4001fa28de5d3eac03c2662556d2d5511b0a3 Mon Sep 17 00:00:00 2001 From: Friedemann Kleint Date: Mon, 9 Sep 2019 17:09:45 +0200 Subject: Fix qdoc warnings src/corelib/global/qnamespace.qdoc:3279: (qdoc) warning: Can't link to 'QGuiApplication::setHighDdpiScaleFactorRoundingPolicy()' src/corelib/time/qislamiccivilcalendar.cpp:49: (qdoc) warning: Can't link to 'QJijriCalendar' src/network/ssl/qsslsocket.cpp:1510: (qdoc) warning: Can't link to 'QSslConfiguration::defaultCaCertificates()' src/network/access/qhttp2configuration.cpp:49: (qdoc) warning: '\brief' statement does not end with a full stop. src/gui/text/qtextformat.cpp:532: (qdoc) warning: Undocumented enum item 'TableBorderCollapse' in QTextFormat::Property src/gui/text/qtextdocument.cpp:2066: (qdoc) warning: Undocumented enum item 'UnknownResource' in QTextDocument::ResourceType src/gui/kernel/qguiapplication.cpp:3500: (qdoc) warning: Undocumented parameter 'policy' in QGuiApplication::setHighDpiScaleFactorRoundingPolicy() Change-Id: I3573ef98cf9b58d16525c356270fe009fdffcf45 Reviewed-by: Shawn Rutledge --- src/widgets/styles/qstyleoption.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/widgets') diff --git a/src/widgets/styles/qstyleoption.cpp b/src/widgets/styles/qstyleoption.cpp index 5b3efd598f..01cadd9a86 100644 --- a/src/widgets/styles/qstyleoption.cpp +++ b/src/widgets/styles/qstyleoption.cpp @@ -1760,7 +1760,7 @@ QStyleOptionMenuItem::QStyleOptionMenuItem(int version) \value Exclusive The item is an exclusive check item (like a radio button). \value NonExclusive The item is a non-exclusive check item (like a check box). - \sa checkType, QAction::checkable, QAction::checked, QActionGroup::exclusive + \sa checkType, QAction::checkable, QAction::checked, QActionGroup::exclusionPolicy */ /*! -- cgit v1.2.3 From b68ade8282274c2d4ee1e4f861d34ea0655c1eab Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thorbj=C3=B8rn=20Lund=20Martsum?= Date: Fri, 16 Aug 2019 08:24:22 +0200 Subject: QStyleSheet: Resolve the rule font before it is used MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The styleSheet font cannot know about e.g dpi or other settings (e.g from the current screen) so we should resolve font settings from the original font. This patch ensures that the stylesheet font is resolved with a relevant font before it is used. This likely fixes many dual/triple screen issues. [ChangeLog][QtWidgets][QStyle] Style sheets now only use the part of the stylesheet font that it knows about. The remaining will be resolved/inherited from the context. Fixes: QTBUG-77502 Change-Id: I3b1f821e1be9707506a6c1d1e93f76eeac4007e0 Reviewed-by: Morten Kristensen Reviewed-by: David Faure Reviewed-by: Christian Ehrlicher Reviewed-by: Morten Johan Sørvig --- src/widgets/styles/qstylesheetstyle.cpp | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) (limited to 'src/widgets') diff --git a/src/widgets/styles/qstylesheetstyle.cpp b/src/widgets/styles/qstylesheetstyle.cpp index dd225fbec3..48d2e268b8 100644 --- a/src/widgets/styles/qstylesheetstyle.cpp +++ b/src/widgets/styles/qstylesheetstyle.cpp @@ -615,7 +615,7 @@ public: public: int features; QBrush defaultBackground; - QFont font; + QFont font; // Be careful using this font directly. Prefer using font.resolve( ) bool hasFont; QHash styleHints; @@ -3211,7 +3211,7 @@ void QStyleSheetStyle::drawComplexControl(ComplexControl cc, const QStyleOptionC rule.drawRule(p, opt->rect); toolOpt.rect = rule.contentsRect(opt->rect); if (rule.hasFont) - toolOpt.font = rule.font; + toolOpt.font = rule.font.resolve(toolOpt.font); drawControl(CE_ToolButtonLabel, &toolOpt, p, w); } @@ -3514,7 +3514,7 @@ void QStyleSheetStyle::drawControl(ControlElement ce, const QStyleOption *opt, Q const QFont oldFont = p->font(); if (rule.hasFont) - p->setFont(rule.font); + p->setFont(rule.font.resolve(p->font())); if (rule.hasPosition() && rule.position()->textAlignment != 0) { Qt::Alignment textAlignment = rule.position()->textAlignment; @@ -3678,7 +3678,7 @@ void QStyleSheetStyle::drawControl(ControlElement ce, const QStyleOption *opt, Q subRule.configurePalette(&mi.palette, QPalette::HighlightedText, QPalette::Highlight); QFont oldFont = p->font(); if (subRule.hasFont) - p->setFont(subRule.font.resolve(p->font())); + p->setFont(subRule.font.resolve(mi.font)); else p->setFont(mi.font); @@ -4084,7 +4084,7 @@ void QStyleSheetStyle::drawControl(ControlElement ce, const QStyleOption *opt, Q subRule.configurePalette(&boxCopy.palette, QPalette::ButtonText, QPalette::Button); QFont oldFont = p->font(); if (subRule.hasFont) - p->setFont(subRule.font); + p->setFont(subRule.font.resolve(p->font())); boxCopy.rect = subRule.contentsRect(opt->rect); if (subRule.hasImage()) { // the image is already drawn with CE_ToolBoxTabShape, adjust rect here @@ -4171,7 +4171,7 @@ void QStyleSheetStyle::drawControl(ControlElement ce, const QStyleOption *opt, Q subRule.configurePalette(&tabCopy.palette, QPalette::WindowText, QPalette::Base); QFont oldFont = p->font(); if (subRule.hasFont) - p->setFont(subRule.font); + p->setFont(subRule.font.resolve(p->font())); if (subRule.hasBox() || !subRule.hasNativeBorder()) { tabCopy.rect = ce == CE_TabBarTabShape ? subRule.borderRect(r) : subRule.contentsRect(r); @@ -5035,8 +5035,12 @@ QSize QStyleSheetStyle::sizeFromContents(ContentsType ct, const QStyleOption *op bool nullIcon = hdr->icon.isNull(); const int margin = pixelMetric(QStyle::PM_HeaderMargin, hdr, w); int iconSize = nullIcon ? 0 : pixelMetric(QStyle::PM_SmallIconSize, hdr, w); - const QSize txt = subRule.hasFont ? QFontMetrics(subRule.font).size(0, hdr->text) - : hdr->fontMetrics.size(0, hdr->text); + QFontMetrics fm = hdr->fontMetrics; + if (subRule.hasFont) { + QFont styleFont = w ? subRule.font.resolve(w->font()) : subRule.font; + fm = QFontMetrics(styleFont); + } + const QSize txt = fm.size(0, hdr->text); nativeContentsSize.setHeight(margin + qMax(iconSize, txt.height()) + margin); nativeContentsSize.setWidth((nullIcon ? 0 : margin) + iconSize + (hdr->text.isNull() ? 0 : margin) + txt.width() + margin); -- cgit v1.2.3 From b01e69684b9b36492cc43472edeb72058be9f706 Mon Sep 17 00:00:00 2001 From: Alberto Mardegan Date: Fri, 6 Sep 2019 21:42:59 +0300 Subject: Fusion: reduce width of menu items The extra spacing for menu items was being computed twice: once in QCommonStyle and once in QFusionStyle, resulting in excessive width. Task-number: QTBUG-78093 Change-Id: Id5f3568cf469e57d18ce8548ab480753e7244952 Reviewed-by: Christian Ehrlicher --- src/widgets/styles/qfusionstyle.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/widgets') diff --git a/src/widgets/styles/qfusionstyle.cpp b/src/widgets/styles/qfusionstyle.cpp index ba2b6b0ed9..e98f6edb8b 100644 --- a/src/widgets/styles/qfusionstyle.cpp +++ b/src/widgets/styles/qfusionstyle.cpp @@ -3232,7 +3232,7 @@ QSize QFusionStyle::sizeFromContents(ContentsType type, const QStyleOption *opti break; case CT_MenuItem: if (const QStyleOptionMenuItem *menuItem = qstyleoption_cast(option)) { - int w = newSize.width(); + int w = size.width(); // Don't rely of QCommonStyle's width calculation here int maxpmw = menuItem->maxIconWidth; int tabSpacing = 20; if (menuItem->text.contains(QLatin1Char('\t'))) -- cgit v1.2.3 From 02e43e6fa6f47eaedc1dd72956569aa939d90981 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tor=20Arne=20Vestb=C3=B8?= Date: Wed, 28 Aug 2019 16:56:18 +0200 Subject: widgets: Remove use of deprecated activated(const QString &) API MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Change-Id: I71c6a10f6593ac28bf8f60d9db8d167cf88715cb Reviewed-by: Paul Olav Tvete Reviewed-by: Tor Arne Vestbø --- src/widgets/widgets/qcombobox.cpp | 15 --------------- src/widgets/widgets/qcombobox_p.h | 10 ++++++++++ 2 files changed, 10 insertions(+), 15 deletions(-) (limited to 'src/widgets') diff --git a/src/widgets/widgets/qcombobox.cpp b/src/widgets/widgets/qcombobox.cpp index a53c278aea..9a0e969e1c 100644 --- a/src/widgets/widgets/qcombobox.cpp +++ b/src/widgets/widgets/qcombobox.cpp @@ -2539,21 +2539,6 @@ QSize QComboBox::sizeHint() const } #ifdef Q_OS_MAC - -namespace { -struct IndexSetter { - int index; - QComboBox *cb; - - void operator()(void) - { - cb->setCurrentIndex(index); - emit cb->activated(index); - emit cb->activated(cb->itemText(index)); - } -}; -} - void QComboBoxPrivate::cleanupNativePopup() { if (!m_platformMenu) diff --git a/src/widgets/widgets/qcombobox_p.h b/src/widgets/widgets/qcombobox_p.h index eadb21628f..5967776a61 100644 --- a/src/widgets/widgets/qcombobox_p.h +++ b/src/widgets/widgets/qcombobox_p.h @@ -390,6 +390,16 @@ public: #ifdef Q_OS_MAC void cleanupNativePopup(); bool showNativePopup(); + struct IndexSetter { + int index; + QComboBox *cb; + + void operator()(void) + { + cb->setCurrentIndex(index); + cb->d_func()->emitActivated(cb->d_func()->currentIndex); + } + }; #endif QAbstractItemModel *model; -- cgit v1.2.3 From 72522517688d68a25a543a1da2497a4b8f6b424b Mon Sep 17 00:00:00 2001 From: Friedemann Kleint Date: Thu, 12 Sep 2019 09:43:21 +0200 Subject: Brush up the Windows styles - use range-based for loops where possible - use nullptr - use member initialization - remove a lot of C-style casts - use override - fix some signedness warnings - add some missing break statements Task-number: QTBUG-76493 Change-Id: Ica6ed65ec29e958406e54d816b8a679ed81bd177 Reviewed-by: Oliver Wolff --- src/widgets/styles/qwindowsstyle.cpp | 28 +++++++++++++--------------- src/widgets/styles/qwindowsstyle_p_p.h | 4 ++-- 2 files changed, 15 insertions(+), 17 deletions(-) (limited to 'src/widgets') diff --git a/src/widgets/styles/qwindowsstyle.cpp b/src/widgets/styles/qwindowsstyle.cpp index 72c803cb99..7d4e1fe9e7 100644 --- a/src/widgets/styles/qwindowsstyle.cpp +++ b/src/widgets/styles/qwindowsstyle.cpp @@ -120,10 +120,7 @@ enum QSliderDirection { SlUp, SlDown, SlLeft, SlRight }; \internal */ -QWindowsStylePrivate::QWindowsStylePrivate() - : alt_down(false), menuBarTimer(0) -{ -} +QWindowsStylePrivate::QWindowsStylePrivate() = default; qreal QWindowsStylePrivate::appDevicePixelRatio() { @@ -157,7 +154,7 @@ bool QWindowsStyle::eventFilter(QObject *o, QEvent *e) QList l = widget->findChildren(); auto ignorable = [](QWidget *w) { return w->isWindow() || !w->isVisible() - || w->style()->styleHint(SH_UnderlineShortcut, 0, w); + || w->style()->styleHint(SH_UnderlineShortcut, nullptr, w); }; l.erase(std::remove_if(l.begin(), l.end(), ignorable), l.end()); // Update states before repainting @@ -242,7 +239,7 @@ void QWindowsStyle::polish(QApplication *app) QCommonStyle::polish(app); QWindowsStylePrivate *d = const_cast(d_func()); // We only need the overhead when shortcuts are sometimes hidden - if (!proxy()->styleHint(SH_UnderlineShortcut, 0) && app) + if (!proxy()->styleHint(SH_UnderlineShortcut, nullptr) && app) app->installEventFilter(this); const auto &palette = QGuiApplication::palette(); @@ -343,7 +340,6 @@ int QWindowsStylePrivate::fixedPixelMetric(QStyle::PixelMetric pm) case QStyle::PM_MenuVMargin: case QStyle::PM_ToolBarItemMargin: return 1; - break; case QStyle::PM_DockWidgetSeparatorExtent: return 4; #if QT_CONFIG(tabbar) @@ -698,17 +694,17 @@ void QWindowsStyle::drawPrimitive(PrimitiveElement pe, const QStyleOption *opt, x -= 2; if (opt->rect.height() > 4) { qDrawShadePanel(p, x, 2, 3, opt->rect.height() - 4, - opt->palette, false, 1, 0); + opt->palette, false, 1, nullptr); qDrawShadePanel(p, x + 3, 2, 3, opt->rect.height() - 4, - opt->palette, false, 1, 0); + opt->palette, false, 1, nullptr); } } else { if (opt->rect.width() > 4) { int y = opt->rect.height() / 2 - 4; qDrawShadePanel(p, 2, y, opt->rect.width() - 4, 3, - opt->palette, false, 1, 0); + opt->palette, false, 1, nullptr); qDrawShadePanel(p, 2, y + 3, opt->rect.width() - 4, 3, - opt->palette, false, 1, 0); + opt->palette, false, 1, nullptr); } } p->restore(); @@ -759,7 +755,7 @@ void QWindowsStyle::drawPrimitive(PrimitiveElement pe, const QStyleOption *opt, } } else { qDrawWinButton(p, opt->rect, opt->palette, - opt->state & (State_Sunken | State_On), panel ? &fill : 0); + opt->state & (State_Sunken | State_On), panel ? &fill : nullptr); } } else { p->fillRect(opt->rect, fill); @@ -980,7 +976,7 @@ void QWindowsStyle::drawPrimitive(PrimitiveElement pe, const QStyleOption *opt, if (opt->state & (State_Raised | State_On | State_Sunken)) { qDrawWinButton(p, opt->rect, opt->palette, opt->state & (State_Sunken | State_On), - panel ? &fill : 0); + panel ? &fill : nullptr); } else { if (panel) p->fillRect(opt->rect, fill); @@ -1005,7 +1001,7 @@ void QWindowsStyle::drawPrimitive(PrimitiveElement pe, const QStyleOption *opt, #endif // QT_CONFIG(dockwidget) case PE_FrameStatusBarItem: - qDrawShadePanel(p, opt->rect, opt->palette, true, 1, 0); + qDrawShadePanel(p, opt->rect, opt->palette, true, 1, nullptr); break; case PE_IndicatorProgressChunk: @@ -1043,7 +1039,7 @@ void QWindowsStyle::drawPrimitive(PrimitiveElement pe, const QStyleOption *opt, break; case PE_FrameTabWidget: { - qDrawWinButton(p, opt->rect, opt->palette, false, 0); + qDrawWinButton(p, opt->rect, opt->palette, false, nullptr); break; } default: @@ -1585,6 +1581,7 @@ void QWindowsStyle::drawControl(ControlElement ce, const QStyleOption *opt, QPai case QStyleOptionToolBar::Beginning: case QStyleOptionToolBar::OnlyOne: paintBottomBorder = false; + break; default: break; } @@ -1600,6 +1597,7 @@ void QWindowsStyle::drawControl(ControlElement ce, const QStyleOption *opt, QPai case QStyleOptionToolBar::OnlyOne: paintRightBorder = false; paintLeftBorder = false; + break; default: break; } diff --git a/src/widgets/styles/qwindowsstyle_p_p.h b/src/widgets/styles/qwindowsstyle_p_p.h index e6ea809f11..4f6ffcefc2 100644 --- a/src/widgets/styles/qwindowsstyle_p_p.h +++ b/src/widgets/styles/qwindowsstyle_p_p.h @@ -77,9 +77,9 @@ public: bool hasSeenAlt(const QWidget *widget) const; bool altDown() const { return alt_down; } - bool alt_down; + bool alt_down = false; QList seenAlt; - int menuBarTimer; + int menuBarTimer = 0; QColor inactiveCaptionText; QColor activeCaptionColor; -- cgit v1.2.3 From 9c76b82885253bbec9d9019b9113be16b15385f2 Mon Sep 17 00:00:00 2001 From: Friedemann Kleint Date: Thu, 12 Sep 2019 09:32:02 +0200 Subject: Windows style: Fix size of controls in multimonitor-setups with scaling disabled The function calculating a correction for the size of windows metrics depending on screen would bail out when high DPI scaling was disabled. This is wrong since the correction is also needed in that case, delete the clause. Task-number: QTBUG-64890 Change-Id: Idef22e18fc616a211ccac48400490fc52393a338 Reviewed-by: Oliver Wolff --- src/widgets/styles/qwindowsstyle.cpp | 2 -- 1 file changed, 2 deletions(-) (limited to 'src/widgets') diff --git a/src/widgets/styles/qwindowsstyle.cpp b/src/widgets/styles/qwindowsstyle.cpp index 7d4e1fe9e7..8496a2c223 100644 --- a/src/widgets/styles/qwindowsstyle.cpp +++ b/src/widgets/styles/qwindowsstyle.cpp @@ -392,8 +392,6 @@ static QScreen *screenOf(const QWidget *w) // and account for secondary screens with differing logical DPI. qreal QWindowsStylePrivate::nativeMetricScaleFactor(const QWidget *widget) { - if (!QHighDpiScaling::isActive()) - return 1; qreal result = qreal(1) / QWindowsStylePrivate::devicePixelRatio(widget); if (QGuiApplicationPrivate::screen_list.size() > 1) { const QScreen *primaryScreen = QGuiApplication::primaryScreen(); -- cgit v1.2.3 From cdb7d013cbdd7bec2e518ef5cd7b0b9fd0cfd3fb Mon Sep 17 00:00:00 2001 From: Fabian Kosmale Date: Thu, 12 Sep 2019 08:25:01 +0200 Subject: QGraphicsScene: register ItemIndexMethod enum for property Fixes: QTBUG-57903 Change-Id: I2b2725bceb5189dd21102bbacb10e9775740cf5d Reviewed-by: Friedemann Kleint --- src/widgets/graphicsview/qgraphicsscene.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/widgets') diff --git a/src/widgets/graphicsview/qgraphicsscene.h b/src/widgets/graphicsview/qgraphicsscene.h index 3cc00ead08..d36a871533 100644 --- a/src/widgets/graphicsview/qgraphicsscene.h +++ b/src/widgets/graphicsview/qgraphicsscene.h @@ -115,7 +115,7 @@ public: BspTreeIndex, NoIndex = -1 }; - + Q_ENUM(ItemIndexMethod) enum SceneLayer { ItemLayer = 0x1, BackgroundLayer = 0x2, -- cgit v1.2.3 From 57e8fe86bdd3a38e8b968f553a3cfaa6541feee1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thorbj=C3=B8rn=20Lund=20Martsum?= Date: Fri, 16 Aug 2019 08:24:22 +0200 Subject: QStyleSheet: Resolve the rule font before it is used MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The styleSheet font cannot know about e.g dpi or other settings (e.g from the current screen) so we should resolve font settings from the original font. This patch ensures that the stylesheet font is resolved with a relevant font before it is used. This likely fixes many dual/triple screen issues. [ChangeLog][QtWidgets][QStyle] Style sheets now only use the part of the stylesheet font that it knows about. The remaining will be resolved/inherited from the context. Fixes: QTBUG-77502 Change-Id: I3b1f821e1be9707506a6c1d1e93f76eeac4007e0 Reviewed-by: Morten Kristensen Reviewed-by: David Faure Reviewed-by: Christian Ehrlicher Reviewed-by: Morten Johan Sørvig (cherry picked from commit b68ade8282274c2d4ee1e4f861d34ea0655c1eab) Reviewed-by: Friedemann Kleint --- src/widgets/styles/qstylesheetstyle.cpp | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) (limited to 'src/widgets') diff --git a/src/widgets/styles/qstylesheetstyle.cpp b/src/widgets/styles/qstylesheetstyle.cpp index dd225fbec3..48d2e268b8 100644 --- a/src/widgets/styles/qstylesheetstyle.cpp +++ b/src/widgets/styles/qstylesheetstyle.cpp @@ -615,7 +615,7 @@ public: public: int features; QBrush defaultBackground; - QFont font; + QFont font; // Be careful using this font directly. Prefer using font.resolve( ) bool hasFont; QHash styleHints; @@ -3211,7 +3211,7 @@ void QStyleSheetStyle::drawComplexControl(ComplexControl cc, const QStyleOptionC rule.drawRule(p, opt->rect); toolOpt.rect = rule.contentsRect(opt->rect); if (rule.hasFont) - toolOpt.font = rule.font; + toolOpt.font = rule.font.resolve(toolOpt.font); drawControl(CE_ToolButtonLabel, &toolOpt, p, w); } @@ -3514,7 +3514,7 @@ void QStyleSheetStyle::drawControl(ControlElement ce, const QStyleOption *opt, Q const QFont oldFont = p->font(); if (rule.hasFont) - p->setFont(rule.font); + p->setFont(rule.font.resolve(p->font())); if (rule.hasPosition() && rule.position()->textAlignment != 0) { Qt::Alignment textAlignment = rule.position()->textAlignment; @@ -3678,7 +3678,7 @@ void QStyleSheetStyle::drawControl(ControlElement ce, const QStyleOption *opt, Q subRule.configurePalette(&mi.palette, QPalette::HighlightedText, QPalette::Highlight); QFont oldFont = p->font(); if (subRule.hasFont) - p->setFont(subRule.font.resolve(p->font())); + p->setFont(subRule.font.resolve(mi.font)); else p->setFont(mi.font); @@ -4084,7 +4084,7 @@ void QStyleSheetStyle::drawControl(ControlElement ce, const QStyleOption *opt, Q subRule.configurePalette(&boxCopy.palette, QPalette::ButtonText, QPalette::Button); QFont oldFont = p->font(); if (subRule.hasFont) - p->setFont(subRule.font); + p->setFont(subRule.font.resolve(p->font())); boxCopy.rect = subRule.contentsRect(opt->rect); if (subRule.hasImage()) { // the image is already drawn with CE_ToolBoxTabShape, adjust rect here @@ -4171,7 +4171,7 @@ void QStyleSheetStyle::drawControl(ControlElement ce, const QStyleOption *opt, Q subRule.configurePalette(&tabCopy.palette, QPalette::WindowText, QPalette::Base); QFont oldFont = p->font(); if (subRule.hasFont) - p->setFont(subRule.font); + p->setFont(subRule.font.resolve(p->font())); if (subRule.hasBox() || !subRule.hasNativeBorder()) { tabCopy.rect = ce == CE_TabBarTabShape ? subRule.borderRect(r) : subRule.contentsRect(r); @@ -5035,8 +5035,12 @@ QSize QStyleSheetStyle::sizeFromContents(ContentsType ct, const QStyleOption *op bool nullIcon = hdr->icon.isNull(); const int margin = pixelMetric(QStyle::PM_HeaderMargin, hdr, w); int iconSize = nullIcon ? 0 : pixelMetric(QStyle::PM_SmallIconSize, hdr, w); - const QSize txt = subRule.hasFont ? QFontMetrics(subRule.font).size(0, hdr->text) - : hdr->fontMetrics.size(0, hdr->text); + QFontMetrics fm = hdr->fontMetrics; + if (subRule.hasFont) { + QFont styleFont = w ? subRule.font.resolve(w->font()) : subRule.font; + fm = QFontMetrics(styleFont); + } + const QSize txt = fm.size(0, hdr->text); nativeContentsSize.setHeight(margin + qMax(iconSize, txt.height()) + margin); nativeContentsSize.setWidth((nullIcon ? 0 : margin) + iconSize + (hdr->text.isNull() ? 0 : margin) + txt.width() + margin); -- cgit v1.2.3 From 6c0e1dba403ce65285e089bf281319de36d29235 Mon Sep 17 00:00:00 2001 From: Friedemann Kleint Date: Wed, 18 Sep 2019 10:18:31 +0200 Subject: QWizard/AeroStyle: Fix crash when Qt::AA_NativeWindows is set MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Prevent recursive platform window creation from the events received during window creation (WM_POSCHANGING, etc). Fixes: QTBUG-78300 Change-Id: Ie2bb4308af645c30e556666589e2dd08f14d4035 Reviewed-by: André de la Rocha --- src/widgets/dialogs/qwizard.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'src/widgets') diff --git a/src/widgets/dialogs/qwizard.cpp b/src/widgets/dialogs/qwizard.cpp index f6f540f57c..ccbf8491b3 100644 --- a/src/widgets/dialogs/qwizard.cpp +++ b/src/widgets/dialogs/qwizard.cpp @@ -3267,7 +3267,10 @@ bool QWizard::nativeEvent(const QByteArray &eventType, void *message, long *resu if (QVistaHelper::vistaState() != d->vistaState) { d->vistaState = QVistaHelper::vistaState(); d->vistaStateChanged = true; - setWizardStyle(AeroStyle); + // QTBUG-78300: When Qt::AA_NativeWindows is set, delay further + // window creation until after the platform window creation events. + if (windowsMessage->message == WM_GETICON) + setWizardStyle(AeroStyle); } return winEventResult; } else { -- cgit v1.2.3 From 1ceb48c6a6aa7d718a6abfc7390cde387f990ed9 Mon Sep 17 00:00:00 2001 From: Friedemann Kleint Date: Wed, 18 Sep 2019 15:49:07 +0200 Subject: QWizard/AeroStyle: Fix condition introduced by previous fix MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Set the variables within the condition introduced by 6c0e1dba403ce65285e089bf281319de36d29235, as otherwise, the code might not be executed. Task-number: QTBUG-78300 Change-Id: Ia83db6fce197ebf16783f3b0c6d6fad7ebd2ba52 Reviewed-by: André de la Rocha Reviewed-by: Oliver Wolff --- src/widgets/dialogs/qwizard.cpp | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) (limited to 'src/widgets') diff --git a/src/widgets/dialogs/qwizard.cpp b/src/widgets/dialogs/qwizard.cpp index ccbf8491b3..7b26d9a67a 100644 --- a/src/widgets/dialogs/qwizard.cpp +++ b/src/widgets/dialogs/qwizard.cpp @@ -3265,12 +3265,13 @@ bool QWizard::nativeEvent(const QByteArray &eventType, void *message, long *resu MSG *windowsMessage = static_cast(message); const bool winEventResult = d->vistaHelper->handleWinEvent(windowsMessage, result); if (QVistaHelper::vistaState() != d->vistaState) { - d->vistaState = QVistaHelper::vistaState(); - d->vistaStateChanged = true; // QTBUG-78300: When Qt::AA_NativeWindows is set, delay further // window creation until after the platform window creation events. - if (windowsMessage->message == WM_GETICON) + if (windowsMessage->message == WM_GETICON) { + d->vistaStateChanged = true; + d->vistaState = QVistaHelper::vistaState(); setWizardStyle(AeroStyle); + } } return winEventResult; } else { -- cgit v1.2.3 From ecc83677006dc7dffcd2417b1e3cff88b0615756 Mon Sep 17 00:00:00 2001 From: Shawn Rutledge Date: Mon, 17 Jun 2019 17:47:30 +0200 Subject: Add QScreen::virtualSiblingAt() and use it in QMenubarPrivate::popupAction MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit QGuiApplication::screenAt() is documented "If the point maps to more than one set of virtual siblings, the first match is returned." But in many cases it's possible to start from a known screen and consider only its siblings, as when deciding where to open a QMenu from a QMenuBar: the QMenuBar is already shown on some screen(s), so the QMenu must be shown on a sibling from that set. This function should be useful in other such cases too, hence it might as well be public API. Task-number: QTBUG-76162 Change-Id: I83c74b40eb53f56fb285a6074a3dc2c0ea9c570b Reviewed-by: Friedemann Kleint Reviewed-by: Tor Arne Vestbø --- src/widgets/widgets/qmenubar.cpp | 13 ++++--------- 1 file changed, 4 insertions(+), 9 deletions(-) (limited to 'src/widgets') diff --git a/src/widgets/widgets/qmenubar.cpp b/src/widgets/widgets/qmenubar.cpp index 3d31a3b73a..69b1c5896f 100644 --- a/src/widgets/widgets/qmenubar.cpp +++ b/src/widgets/widgets/qmenubar.cpp @@ -324,15 +324,10 @@ void QMenuBarPrivate::popupAction(QAction *action, bool activateFirst) QPoint pos(q->mapToGlobal(QPoint(adjustedActionRect.left(), adjustedActionRect.bottom() + 1))); QSize popup_size = activeMenu->sizeHint(); //we put the popup menu on the screen containing the bottom-center of the action rect - QScreen *popupScreen = q->window()->windowHandle()->screen(); - QPoint bottomMiddlePos = pos + QPoint(adjustedActionRect.width() / 2, 0); - const auto &siblings = popupScreen->virtualSiblings(); - for (QScreen *sibling : siblings) { - if (sibling->geometry().contains(bottomMiddlePos)) { - popupScreen = sibling; - break; - } - } + QScreen *menubarScreen = q->window()->windowHandle()->screen(); + QScreen *popupScreen = menubarScreen->virtualSiblingAt(pos + QPoint(adjustedActionRect.width() / 2, 0)); + if (!popupScreen) + popupScreen = menubarScreen; QRect screenRect = popupScreen->geometry(); pos = QPoint(qMax(pos.x(), screenRect.x()), qMax(pos.y(), screenRect.y())); const bool fitUp = (pos.y() - popup_size.height() >= screenRect.top()); -- cgit v1.2.3 From 9b6179cf957c32e0c02547d510dfee2088f02340 Mon Sep 17 00:00:00 2001 From: Andy Shaw Date: Thu, 5 Sep 2019 12:52:43 +0200 Subject: Ensure all children of a widget get updated when a stylesheet changes Before, only the direct children would get an update when the stylesheet changed, any children below that would be unchanged. Fixes: QTBUG-77006 Change-Id: Id668eaae74a8289d78d66644f077e6a3302960cd Reviewed-by: Frederik Gladhorn --- src/widgets/styles/qstylesheetstyle.cpp | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'src/widgets') diff --git a/src/widgets/styles/qstylesheetstyle.cpp b/src/widgets/styles/qstylesheetstyle.cpp index 85b65f39b1..98a9f74f5b 100644 --- a/src/widgets/styles/qstylesheetstyle.cpp +++ b/src/widgets/styles/qstylesheetstyle.cpp @@ -2735,6 +2735,11 @@ static void updateObjects(const QList& objects) if (auto widget = qobject_cast(const_cast(object))) { widget->style()->polish(widget); QApplication::sendEvent(widget, &event); + QList children; + children.reserve(widget->children().size() + 1); + for (auto child: qAsConst(widget->children())) + children.append(child); + updateObjects(children); } } } -- cgit v1.2.3 From 70c053ee684448984b1f762abd3b40884cece2fa Mon Sep 17 00:00:00 2001 From: Christian Ehrlicher Date: Fri, 20 Sep 2019 22:27:44 +0200 Subject: QAbstractSpinBox css: properly honor spincontrol-disable-on-bounds The css style 'spincontrol-disable-on-bounds' was not properly honored within QAbstractSpinBox::initStyleOption() because the affected widget was not passed to QStyle::styleHint(). Therefore QStyleSheetStyle did not find the correct render rule. Fix it by passing 'this' as third argument to QStyle::styleHint(). Fixes: QTBUG-18008 Change-Id: Iabcebf0b83143f45309b4e7066bccb8d20bd0419 Reviewed-by: Eirik Aavitsland --- src/widgets/widgets/qabstractspinbox.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/widgets') diff --git a/src/widgets/widgets/qabstractspinbox.cpp b/src/widgets/widgets/qabstractspinbox.cpp index d49d9dbd66..fc19e0793e 100644 --- a/src/widgets/widgets/qabstractspinbox.cpp +++ b/src/widgets/widgets/qabstractspinbox.cpp @@ -1726,7 +1726,7 @@ void QAbstractSpinBox::initStyleOption(QStyleOptionSpinBox *option) const option->activeSubControls = d->hoverControl; } - option->stepEnabled = style()->styleHint(QStyle::SH_SpinControls_DisableOnBounds) + option->stepEnabled = style()->styleHint(QStyle::SH_SpinControls_DisableOnBounds, nullptr, this) ? stepEnabled() : (QAbstractSpinBox::StepDownEnabled|QAbstractSpinBox::StepUpEnabled); -- cgit v1.2.3 From 27782af8219e244fb8cea60e3f22448d5d075446 Mon Sep 17 00:00:00 2001 From: Friedemann Kleint Date: Mon, 23 Sep 2019 14:38:13 +0200 Subject: QWizard: Use member initialization in private classes Remove superfluous constructors. Task-number: QTBUG-78604 Change-Id: I8a422cfeaaedf89ce310e06d5db80907cd1102d4 Reviewed-by: Jesus Fernandez --- src/widgets/dialogs/qwizard.cpp | 158 +++++++++++++++------------------------- 1 file changed, 57 insertions(+), 101 deletions(-) (limited to 'src/widgets') diff --git a/src/widgets/dialogs/qwizard.cpp b/src/widgets/dialogs/qwizard.cpp index 7b26d9a67a..b4a5904779 100644 --- a/src/widgets/dialogs/qwizard.cpp +++ b/src/widgets/dialogs/qwizard.cpp @@ -232,31 +232,24 @@ void QWizardField::findProperty(const QWizardDefaultProperty *properties, int pr class QWizardLayoutInfo { public: - inline QWizardLayoutInfo() - : topLevelMarginLeft(-1), topLevelMarginRight(-1), topLevelMarginTop(-1), - topLevelMarginBottom(-1), childMarginLeft(-1), childMarginRight(-1), - childMarginTop(-1), childMarginBottom(-1), hspacing(-1), vspacing(-1), - wizStyle(QWizard::ClassicStyle), header(false), watermark(false), title(false), - subTitle(false), extension(false), sideWidget(false) {} - - int topLevelMarginLeft; - int topLevelMarginRight; - int topLevelMarginTop; - int topLevelMarginBottom; - int childMarginLeft; - int childMarginRight; - int childMarginTop; - int childMarginBottom; - int hspacing; - int vspacing; - int buttonSpacing; - QWizard::WizardStyle wizStyle; - bool header; - bool watermark; - bool title; - bool subTitle; - bool extension; - bool sideWidget; + int topLevelMarginLeft = -1; + int topLevelMarginRight = -1; + int topLevelMarginTop = -1; + int topLevelMarginBottom = -1; + int childMarginLeft = -1; + int childMarginRight = -1; + int childMarginTop = -1; + int childMarginBottom = -1; + int hspacing = -1; + int vspacing = -1; + int buttonSpacing = -1; + QWizard::WizardStyle wizStyle = QWizard::ClassicStyle; + bool header = false; + bool watermark = false; + bool title = false; + bool subTitle = false; + bool extension = false; + bool sideWidget = false; bool operator==(const QWizardLayoutInfo &other); inline bool operator!=(const QWizardLayoutInfo &other) { return !operator==(other); } @@ -486,21 +479,18 @@ class QWizardPagePrivate : public QWidgetPrivate public: enum TriState { Tri_Unknown = -1, Tri_False, Tri_True }; - inline QWizardPagePrivate() - : wizard(0), completeState(Tri_Unknown), explicitlyFinal(false), commit(false) {} - bool cachedIsComplete() const; void _q_maybeEmitCompleteChanged(); void _q_updateCachedCompleteState(); - QWizard *wizard; + QWizard *wizard = nullptr; QString title; QString subTitle; QPixmap pixmaps[QWizard::NPixmaps]; QVector pendingFields; - mutable TriState completeState; - bool explicitlyFinal; - bool commit; + mutable TriState completeState = Tri_Unknown; + bool explicitlyFinal = false; + bool commit = false; bool initialized = false; QMap buttonCustomTexts; }; @@ -556,42 +546,6 @@ public: Forward }; - inline QWizardPrivate() - : start(-1) - , startSetByUser(false) - , current(-1) - , canContinue(false) - , canFinish(false) - , disableUpdatesCount(0) - , wizStyle(QWizard::ClassicStyle) - , opts(0) - , buttonsHaveCustomLayout(false) - , titleFmt(Qt::AutoText) - , subTitleFmt(Qt::AutoText) - , placeholderWidget1(0) - , placeholderWidget2(0) - , headerWidget(0) - , watermarkLabel(0) - , sideWidget(0) - , pageFrame(0) - , titleLabel(0) - , subTitleLabel(0) - , bottomRuler(0) -#if QT_CONFIG(style_windowsvista) - , vistaHelper(0) - , vistaInitPending(true) - , vistaState(QVistaHelper::Dirty) - , vistaStateChanged(false) - , inHandleAeroStyleChange(false) -#endif - , minimumWidth(0) - , minimumHeight(0) - , maximumWidth(QWIDGETSIZE_MAX) - , maximumHeight(QWIDGETSIZE_MAX) - { - std::fill(btns, btns + QWizard::NButtons, static_cast(0)); - } - void init(); void reset(); void cleanupPagesNotInHistory(); @@ -631,21 +585,21 @@ public: QMap fieldIndexMap; QVector defaultPropertyTable; QList history; - int start; - bool startSetByUser; - int current; - bool canContinue; - bool canFinish; + int start = -1; + bool startSetByUser = false; + int current = -1; + bool canContinue = false; + bool canFinish = false; QWizardLayoutInfo layoutInfo; - int disableUpdatesCount; + int disableUpdatesCount = 0; - QWizard::WizardStyle wizStyle; + QWizard::WizardStyle wizStyle = QWizard::ClassicStyle; QWizard::WizardOptions opts; QMap buttonCustomTexts; - bool buttonsHaveCustomLayout; + bool buttonsHaveCustomLayout = false; QList buttonsCustomLayout; - Qt::TextFormat titleFmt; - Qt::TextFormat subTitleFmt; + Qt::TextFormat titleFmt = Qt::AutoText; + Qt::TextFormat subTitleFmt = Qt::AutoText; mutable QPixmap defaultPixmaps[QWizard::NPixmaps]; union { @@ -660,32 +614,32 @@ public: } btn; mutable QAbstractButton *btns[QWizard::NButtons]; }; - QWizardAntiFlickerWidget *antiFlickerWidget; - QWidget *placeholderWidget1; - QWidget *placeholderWidget2; - QWizardHeader *headerWidget; - QWatermarkLabel *watermarkLabel; - QWidget *sideWidget; - QFrame *pageFrame; - QLabel *titleLabel; - QLabel *subTitleLabel; - QWizardRuler *bottomRuler; - - QVBoxLayout *pageVBoxLayout; - QHBoxLayout *buttonLayout; - QGridLayout *mainLayout; + QWizardAntiFlickerWidget *antiFlickerWidget = nullptr; + QWidget *placeholderWidget1 = nullptr; + QWidget *placeholderWidget2 = nullptr; + QWizardHeader *headerWidget = nullptr; + QWatermarkLabel *watermarkLabel = nullptr; + QWidget *sideWidget = nullptr; + QFrame *pageFrame = nullptr; + QLabel *titleLabel = nullptr; + QLabel *subTitleLabel = nullptr; + QWizardRuler *bottomRuler = nullptr; + + QVBoxLayout *pageVBoxLayout = nullptr; + QHBoxLayout *buttonLayout = nullptr; + QGridLayout *mainLayout = nullptr; #if QT_CONFIG(style_windowsvista) - QVistaHelper *vistaHelper; - bool vistaInitPending; - QVistaHelper::VistaState vistaState; - bool vistaStateChanged; - bool inHandleAeroStyleChange; + QVistaHelper *vistaHelper = nullptr; + bool vistaInitPending = true; + QVistaHelper::VistaState vistaState = QVistaHelper::Dirty; + bool vistaStateChanged = false; + bool inHandleAeroStyleChange = false; #endif - int minimumWidth; - int minimumHeight; - int maximumWidth; - int maximumHeight; + int minimumWidth = 0; + int minimumHeight = 0; + int maximumWidth = QWIDGETSIZE_MAX; + int maximumHeight = QWIDGETSIZE_MAX; }; static QString buttonDefaultText(int wstyle, int which, const QWizardPrivate *wizardPrivate) @@ -720,6 +674,8 @@ void QWizardPrivate::init() { Q_Q(QWizard); + std::fill(btns, btns + QWizard::NButtons, nullptr); + antiFlickerWidget = new QWizardAntiFlickerWidget(q, this); wizStyle = QWizard::WizardStyle(q->style()->styleHint(QStyle::SH_WizardStyle, 0, q)); if (wizStyle == QWizard::MacStyle) { -- cgit v1.2.3 From 8810f82f3f9b3fe35d82fb842a5a21a098b2343f Mon Sep 17 00:00:00 2001 From: Friedemann Kleint Date: Mon, 23 Sep 2019 14:49:07 +0200 Subject: QWizard/Aerostyle: Fix "&Next" shortcut The fix for QTBUG-35203 set the Alt+Right shortcut on the next button, clobbering the Alt+N shortcut from parsing the text (similar for other languages). Add a separate shortcut for Alt+Right since a button may not have several shortcuts. Amends 6714196f45fbae755b26a4b2406a7bbe066084dc. Fixes: QTBUG-78604 Change-Id: I1367da739c35fbd011d11f850c9bc3915113c644 Reviewed-by: Oliver Wolff --- src/widgets/dialogs/qwizard.cpp | 22 ++++++++++++++++++---- 1 file changed, 18 insertions(+), 4 deletions(-) (limited to 'src/widgets') diff --git a/src/widgets/dialogs/qwizard.cpp b/src/widgets/dialogs/qwizard.cpp index b4a5904779..5ba48aeff3 100644 --- a/src/widgets/dialogs/qwizard.cpp +++ b/src/widgets/dialogs/qwizard.cpp @@ -55,10 +55,14 @@ #if QT_CONFIG(lineedit) #include "qlineedit.h" #endif +#include #include "qpainter.h" #include "qwindow.h" #include "qpushbutton.h" #include "qset.h" +#if QT_CONFIG(shortcut) +# include "qshortcut.h" +#endif #include "qstyle.h" #include "qvarlengtharray.h" #if defined(Q_OS_MACX) @@ -631,6 +635,9 @@ public: #if QT_CONFIG(style_windowsvista) QVistaHelper *vistaHelper = nullptr; +# if QT_CONFIG(shortcut) + QPointer vistaNextShortcut; +# endif bool vistaInitPending = true; QVistaHelper::VistaState vistaState = QVistaHelper::Dirty; bool vistaStateChanged = false; @@ -1417,10 +1424,17 @@ void QWizardPrivate::updateButtonTexts() // Vista: Add shortcut for 'next'. Note: native dialogs use ALT-Right // even in RTL mode, so do the same, even if it might be counter-intuitive. // The shortcut for 'back' is set in class QVistaBackButton. -#if QT_CONFIG(shortcut) - if (btns[QWizard::NextButton] && isVistaThemeEnabled()) - btns[QWizard::NextButton]->setShortcut(QKeySequence(Qt::ALT | Qt::Key_Right)); -#endif +#if QT_CONFIG(shortcut) && QT_CONFIG(style_windowsvista) + if (btns[QWizard::NextButton] && isVistaThemeEnabled()) { + if (vistaNextShortcut.isNull()) { + vistaNextShortcut = + new QShortcut(QKeySequence(Qt::ALT | Qt::Key_Right), + btns[QWizard::NextButton], SLOT(animateClick())); + } + } else { + delete vistaNextShortcut; + } +#endif // shortcut && style_windowsvista } void QWizardPrivate::updateButtonLayout() -- cgit v1.2.3 From 947883141d9d8b3079a8a21981ad8a5ce3c4798e Mon Sep 17 00:00:00 2001 From: David Faure Date: Mon, 9 Sep 2019 18:12:26 +0200 Subject: QWidget::setFocusProxy: adjust focus widget properly My commit 3e7463411e adjusted the focus widget by setting QApplicationPrivate::focus_widget directly, while there is a method for doing this properly, including setFocus_sys() and emitting signals. Fixes: QTBUG-77364 Change-Id: I218acf7a9de39173d282ced46def4f65594f80b4 Reviewed-by: Florian Bruhin Reviewed-by: Volker Hilsheimer Reviewed-by: Allan Sandfeld Jensen Reviewed-by: Shawn Rutledge --- src/widgets/kernel/qwidget.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/widgets') diff --git a/src/widgets/kernel/qwidget.cpp b/src/widgets/kernel/qwidget.cpp index 04290a4ce1..0fa5907744 100644 --- a/src/widgets/kernel/qwidget.cpp +++ b/src/widgets/kernel/qwidget.cpp @@ -6446,7 +6446,7 @@ void QWidget::setFocusProxy(QWidget * w) if (changingAppFocusWidget) { QWidget *newDeepestFocusProxy = d_func()->deepestFocusProxy(); - QApplicationPrivate::focus_widget = newDeepestFocusProxy ? newDeepestFocusProxy : this; + QApplicationPrivate::setFocusWidget(newDeepestFocusProxy ? newDeepestFocusProxy : this, Qt::NoFocusReason); } } -- cgit v1.2.3 From 688369999435d6f4755577fe47ff80132254bb26 Mon Sep 17 00:00:00 2001 From: Kai Uwe Broulik Date: Fri, 5 Jul 2019 13:43:02 +0200 Subject: QCommonStyle: Add SP_DialogNoButton case in standardIcon It is present in standardPixmap but missing from standardIcon resulting in QMessageBox using the fallback PNG provided by Qt for the "No" button. Change-Id: If4f14c7de26eb32277cd19a7be75360dba4f4e29 Reviewed-by: Christian Ehrlicher --- src/widgets/styles/qcommonstyle.cpp | 1 + 1 file changed, 1 insertion(+) (limited to 'src/widgets') diff --git a/src/widgets/styles/qcommonstyle.cpp b/src/widgets/styles/qcommonstyle.cpp index 3db85ca07a..271b43fe89 100644 --- a/src/widgets/styles/qcommonstyle.cpp +++ b/src/widgets/styles/qcommonstyle.cpp @@ -5967,6 +5967,7 @@ QIcon QCommonStyle::standardIcon(StandardPixmap standardIcon, const QStyleOption case SP_ArrowLeft: icon = QIcon::fromTheme(QLatin1String("go-previous")); break; + case SP_DialogNoButton: case SP_DialogCancelButton: icon = QIcon::fromTheme(QLatin1String("dialog-cancel"), QIcon::fromTheme(QLatin1String("process-stop"))); -- cgit v1.2.3 From e02293a76d21e7077f1952d4ed8af6c6d1970190 Mon Sep 17 00:00:00 2001 From: Andy Shaw Date: Mon, 30 Sep 2019 08:26:36 +0200 Subject: Always update the pressed position when pressing on an item If there is an item already selected then the pressed position needs to be updated regardless when selecting a new one even if it is not made current as this will be used to determine the drag distance. Otherwise it will start a drag within one pixel of moving due to the fact it is doing it relative to the first item to be pressed rather than the last. Fixes: QTBUG-78797 Change-Id: I853041b278b2e92ccf20660f7ced945fef72527a Reviewed-by: Samuel Gaist Reviewed-by: Christian Ehrlicher --- src/widgets/itemviews/qabstractitemview.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/widgets') diff --git a/src/widgets/itemviews/qabstractitemview.cpp b/src/widgets/itemviews/qabstractitemview.cpp index cb99214d4e..7d5e014dd5 100644 --- a/src/widgets/itemviews/qabstractitemview.cpp +++ b/src/widgets/itemviews/qabstractitemview.cpp @@ -1775,8 +1775,8 @@ void QAbstractItemView::mousePressEvent(QMouseEvent *event) QItemSelectionModel::SelectionFlags command = selectionCommand(index, event); d->noSelectionOnMousePress = command == QItemSelectionModel::NoUpdate || !index.isValid(); QPoint offset = d->offset(); + d->pressedPosition = pos + offset; if ((command & QItemSelectionModel::Current) == 0) { - d->pressedPosition = pos + offset; d->currentSelectionStartIndex = index; } else if (!d->currentSelectionStartIndex.isValid()) -- cgit v1.2.3 From ad86c2f0abb4fab5bf871fe49b37e0a2f4a346bc Mon Sep 17 00:00:00 2001 From: Shawn Rutledge Date: Wed, 2 Oct 2019 14:08:34 +0200 Subject: Quiet several more warnings about QWheelEvent deprecations We want to ensure that the qt4D and qt4O members are still initialized the same way whenever deprecated constructors are used; and we want to be able to verify it using qDebug. So we merely suppress these warnings. Change-Id: Ic2e5f0dd6feeabe81f06f9c31693c550ac0781e3 Reviewed-by: Thiago Macieira --- src/widgets/kernel/qapplication.cpp | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'src/widgets') diff --git a/src/widgets/kernel/qapplication.cpp b/src/widgets/kernel/qapplication.cpp index 629c696544..3223781b63 100644 --- a/src/widgets/kernel/qapplication.cpp +++ b/src/widgets/kernel/qapplication.cpp @@ -3224,8 +3224,11 @@ bool QApplication::notify(QObject *receiver, QEvent *e) QApplicationPrivate::giveFocusAccordingToFocusPolicy(w, e, relpos); #if QT_DEPRECATED_SINCE(5, 14) +QT_WARNING_PUSH +QT_WARNING_DISABLE_DEPRECATED QWheelEvent we(relpos, wheel->globalPos(), wheel->pixelDelta(), wheel->angleDelta(), wheel->delta(), wheel->orientation(), wheel->buttons(), wheel->modifiers(), phase, wheel->source(), wheel->inverted()); +QT_WARNING_POP #else QWheelEvent we(relpos, wheel->globalPosition(), wheel->pixelDelta(), wheel->angleDelta(), wheel->buttons(), wheel->modifiers(), phase, wheel->inverted(), wheel->source()); @@ -3266,8 +3269,11 @@ bool QApplication::notify(QObject *receiver, QEvent *e) // the end of the natural scrolling sequence. const QPoint &relpos = QApplicationPrivate::wheel_widget->mapFromGlobal(wheel->globalPosition().toPoint()); #if QT_DEPRECATED_SINCE(5, 0) +QT_WARNING_PUSH +QT_WARNING_DISABLE_DEPRECATED QWheelEvent we(relpos, wheel->globalPos(), wheel->pixelDelta(), wheel->angleDelta(), wheel->delta(), wheel->orientation(), wheel->buttons(), wheel->modifiers(), wheel->phase(), wheel->source()); +QT_WARNING_POP #else QWheelEvent we(relpos, wheel->globalPosition(), wheel->pixelDelta(), wheel->angleDelta(), wheel->buttons(), wheel->modifiers(), wheel->phase(), wheel->inverted(), wheel->source()); -- cgit v1.2.3 From 7d73d4b9a93b3132c1a24aa3ae77f0a307e821fd Mon Sep 17 00:00:00 2001 From: Andy Shaw Date: Tue, 20 Aug 2019 10:53:53 +0200 Subject: Remove the unregistered recognizer from the main list This amends 1320b2f64412f0d86bd09c66c22df845e13a94a1 to keep the behavior of removing from the main list but without re-introducing the memory leak. Fixes: QTBUG-77770 Change-Id: I91fa6cb71fab8d60baa35417fdb34322af11dbbb Reviewed-by: Friedemann Kleint Reviewed-by: Richard Moe Gustavsen --- src/widgets/kernel/qgesturemanager.cpp | 1 + 1 file changed, 1 insertion(+) (limited to 'src/widgets') diff --git a/src/widgets/kernel/qgesturemanager.cpp b/src/widgets/kernel/qgesturemanager.cpp index cd27c9c5be..5d2adc1e1c 100644 --- a/src/widgets/kernel/qgesturemanager.cpp +++ b/src/widgets/kernel/qgesturemanager.cpp @@ -143,6 +143,7 @@ Qt::GestureType QGestureManager::registerGestureRecognizer(QGestureRecognizer *r void QGestureManager::unregisterGestureRecognizer(Qt::GestureType type) { QList list = m_recognizers.values(type); + m_recognizers.remove(type); foreach (QGesture *g, m_gestureToRecognizer.keys()) { QGestureRecognizer *recognizer = m_gestureToRecognizer.value(g); if (list.contains(recognizer)) { -- cgit v1.2.3 From 5aa13ea144cff4dbadf12c08b7aa49646347e186 Mon Sep 17 00:00:00 2001 From: Andy Shaw Date: Thu, 12 Sep 2019 15:22:24 +0200 Subject: QTreeWidget: Don't assume the selected indexes include the first column If the first column is hidden in a QTreeWidget then when doing a drag then the selected indexes will not include any that have a column of 0. Therefore it has to account for this use std::unique to ensure that there is only one instance of the selected items represented by the selected indexes. Fixes: QTBUG-35511 Change-Id: I39dff596959f30db7378ff946735ee2866778524 Reviewed-by: Richard Moe Gustavsen --- src/widgets/itemviews/qtreewidget.cpp | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) (limited to 'src/widgets') diff --git a/src/widgets/itemviews/qtreewidget.cpp b/src/widgets/itemviews/qtreewidget.cpp index d2dc91b18c..be7ddd8b30 100644 --- a/src/widgets/itemviews/qtreewidget.cpp +++ b/src/widgets/itemviews/qtreewidget.cpp @@ -748,11 +748,14 @@ QMimeData *QTreeModel::internalMimeData() const QMimeData *QTreeModel::mimeData(const QModelIndexList &indexes) const { - QList items; - for (const auto &index : indexes) { - if (index.column() == 0) // only one item per row - items << item(index); - } + QList items; + std::transform(indexes.begin(), indexes.end(), std::back_inserter(items), + [this](const QModelIndex &idx) -> QTreeWidgetItem * { return item(idx); }); + + // Ensure we only have one item as an item may have more than + // one index selected if there is more than one column + std::sort(items.begin(), items.end()); + items.erase(std::unique(items.begin(), items.end()), items.end()); // cachedIndexes is a little hack to avoid copying from QModelIndexList to // QList and back again in the view -- cgit v1.2.3 From 0392a744530ac4868e33d5345c7197ac14d7320d Mon Sep 17 00:00:00 2001 From: Christian Ehrlicher Date: Tue, 24 Sep 2019 11:22:50 +0200 Subject: QItemViews: hide ToolTip/What's this when cell has no data for it A QToolTip/QWhatsThis was not hidden when the cursor moved to a cell which does not return valid data for Qt::ToolTip/WhatsThisRole or when the index is not valid. Therefore a wrong information was shown e.g. when the cursor moved from a cell with a tooltip to one without. Fix it by passing an empty string to QToolTip/QWhatsThis::showText(). This syncs the behavior with QGraphicsScene::helpEvent(). Fixes: QTBUG-78722 Change-Id: Ie99fe3b1d35d2f5be41dd65e2fe3173b0cc551b2 Reviewed-by: Richard Moe Gustavsen --- src/widgets/itemviews/qabstractitemdelegate.cpp | 42 +++++++++++++------------ 1 file changed, 22 insertions(+), 20 deletions(-) (limited to 'src/widgets') diff --git a/src/widgets/itemviews/qabstractitemdelegate.cpp b/src/widgets/itemviews/qabstractitemdelegate.cpp index 31dde8832b..eecc18e5c7 100644 --- a/src/widgets/itemviews/qabstractitemdelegate.cpp +++ b/src/widgets/itemviews/qabstractitemdelegate.cpp @@ -387,44 +387,46 @@ bool QAbstractItemDelegate::helpEvent(QHelpEvent *event, const QStyleOptionViewItem &option, const QModelIndex &index) { - Q_D(QAbstractItemDelegate); - Q_UNUSED(d); - Q_UNUSED(index); - Q_UNUSED(option); - if (!event || !view) return false; + Q_D(QAbstractItemDelegate); switch (event->type()) { #ifndef QT_NO_TOOLTIP case QEvent::ToolTip: { QHelpEvent *he = static_cast(event); const int precision = inherits("QItemDelegate") ? 10 : 6; // keep in sync with DBL_DIG in qitemdelegate.cpp - const QString tooltip = d->textForRole(Qt::ToolTipRole, index.data(Qt::ToolTipRole), option.locale, precision); - if (!tooltip.isEmpty()) { - QToolTip::showText(he->globalPos(), tooltip, view); - return true; + const QString tooltip = index.isValid() ? + d->textForRole(Qt::ToolTipRole, index.data(Qt::ToolTipRole), option.locale, precision) : + QString(); + QRect rect; + if (index.isValid()) { + const QRect r = view->visualRect(index); + rect = QRect(view->mapToGlobal(r.topLeft()), r.size()); + } + QToolTip::showText(he->globalPos(), tooltip, view, rect); + event->setAccepted(!tooltip.isEmpty()); + break; } - break;} #endif #if QT_CONFIG(whatsthis) - case QEvent::QueryWhatsThis: { - if (index.data(Qt::WhatsThisRole).isValid()) - return true; - break; } + case QEvent::QueryWhatsThis: + event->setAccepted(index.data(Qt::WhatsThisRole).isValid()); + break; case QEvent::WhatsThis: { QHelpEvent *he = static_cast(event); const int precision = inherits("QItemDelegate") ? 10 : 6; // keep in sync with DBL_DIG in qitemdelegate.cpp - const QString whatsthis = d->textForRole(Qt::WhatsThisRole, index.data(Qt::WhatsThisRole), option.locale, precision); - if (!whatsthis.isEmpty()) { - QWhatsThis::showText(he->globalPos(), whatsthis, view); - return true; + const QString whatsthis = index.isValid() ? + d->textForRole(Qt::WhatsThisRole, index.data(Qt::WhatsThisRole), option.locale, precision) : + QString(); + QWhatsThis::showText(he->globalPos(), whatsthis, view); + event->setAccepted(!whatsthis.isEmpty()); + break; } - break ; } #endif default: break; } - return false; + return event->isAccepted(); } /*! -- cgit v1.2.3 From 127ed7e6e0f8939861cce7349e28a1dec9a7d6ed Mon Sep 17 00:00:00 2001 From: Albert Astals Cid Date: Fri, 27 Sep 2019 16:27:58 +0200 Subject: QTableWidget: Fix -Wdeprecated-copy warning MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit In file included from ../../include/QtCore/qlist.h:1, from ../../include/QtCore/../../../qtbase_dev_de_verdad/src/corelib/kernel/qobject.h:49, from ../../include/QtCore/qobject.h:1, from ../../include/QtCore/../../../qtbase_dev_de_verdad/src/corelib/kernel/qcoreapplication.h:46, from ../../include/QtCore/qcoreapplication.h:1, from /src/widgets/kernel/../../gui/kernel/../../corelib/global/qt_pch.h:66, from /src/widgets/kernel/../../gui/kernel/qt_gui_pch.h:48, from /src/widgets/kernel/qt_widgets_pch.h:48: ../../include/QtCore/../../../qtbase_dev_de_verdad/src/corelib/tools/qlist.h: In instantiation of ‘void QList::node_construct(QList::Node*, const T&) [with T = QTableWidgetSelectionRange]’: ../../include/QtCore/../../../qtbase_dev_de_verdad/src/corelib/tools/qlist.h:614:13: required from ‘void QList::append(const T&) [with T = QTableWidgetSelectionRange]’ /src/widgets/itemviews/qtablewidget.cpp:2416:71: required from here ../../include/QtCore/../../../qtbase_dev_de_verdad/src/corelib/tools/qlist.h:471:35: warning: implicitly-declared ‘constexpr QTableWidgetSelectionRange& QTableWidgetSelectionRange::operator=(const QTableWidgetSelectionRange&)’ is deprecated [-Wdeprecated-copy] 471 | else *reinterpret_cast(n) = t; | ~~~~~~~~~~~~~~~~~~~~~~~~~^~~ In file included from /src/widgets/itemviews/qtablewidget.cpp:40: /src/widgets/itemviews/qtablewidget.h:52:24: note: because ‘QTableWidgetSelectionRange’ has user-provided ‘QTableWidgetSelectionRange::QTableWidgetSelectionRange(const QTableWidgetSelectionRange&)’ 52 | class Q_WIDGETS_EXPORT QTableWidgetSelectionRange | ^~~~~~~~~~~~~~~~~~~~~~~~~~ Change-Id: I72ca2dbf1d46a0f51a6fc7b7df80c79f937657de Reviewed-by: Christian Ehrlicher Reviewed-by: Friedemann Kleint Reviewed-by: Volker Hilsheimer --- src/widgets/itemviews/qtablewidget.cpp | 6 ++---- src/widgets/itemviews/qtablewidget.h | 5 ++++- 2 files changed, 6 insertions(+), 5 deletions(-) (limited to 'src/widgets') diff --git a/src/widgets/itemviews/qtablewidget.cpp b/src/widgets/itemviews/qtablewidget.cpp index a25a582881..b1dbafa997 100644 --- a/src/widgets/itemviews/qtablewidget.cpp +++ b/src/widgets/itemviews/qtablewidget.cpp @@ -923,10 +923,8 @@ QTableWidgetSelectionRange::QTableWidgetSelectionRange(int top, int left, int bo Constructs a the table selection range by copying the given \a other table selection range. */ -QTableWidgetSelectionRange::QTableWidgetSelectionRange(const QTableWidgetSelectionRange &other) - : top(other.top), left(other.left), bottom(other.bottom), right(other.right) -{ -} +QTableWidgetSelectionRange::QTableWidgetSelectionRange(const QTableWidgetSelectionRange &other) = default; +QTableWidgetSelectionRange &QTableWidgetSelectionRange::operator=(const QTableWidgetSelectionRange &other) = default; /*! Destroys the table selection range. diff --git a/src/widgets/itemviews/qtablewidget.h b/src/widgets/itemviews/qtablewidget.h index d93032f3f0..0d93a0a075 100644 --- a/src/widgets/itemviews/qtablewidget.h +++ b/src/widgets/itemviews/qtablewidget.h @@ -49,14 +49,17 @@ QT_REQUIRE_CONFIG(tablewidget); QT_BEGIN_NAMESPACE +// ### Qt6 unexport the class, remove the user-defined special 3 and make it a literal type. class Q_WIDGETS_EXPORT QTableWidgetSelectionRange { public: QTableWidgetSelectionRange(); QTableWidgetSelectionRange(int top, int left, int bottom, int right); - QTableWidgetSelectionRange(const QTableWidgetSelectionRange &other); ~QTableWidgetSelectionRange(); + QTableWidgetSelectionRange(const QTableWidgetSelectionRange &other); + QTableWidgetSelectionRange &operator=(const QTableWidgetSelectionRange &other); + inline int topRow() const { return top; } inline int bottomRow() const { return bottom; } inline int leftColumn() const { return left; } -- cgit v1.2.3 From bfed3cf41947baec29e88585cfdebf8ebae6ad39 Mon Sep 17 00:00:00 2001 From: Lars Knoll Date: Wed, 2 Oct 2019 12:10:28 +0200 Subject: Get rid of QList forward declarations Include qcontainerfwd.h instead where required. This prepares for unifying QList and QVector. Change-Id: I6c85e2bdd44fb41aedd884b0d551f682760df5b5 Reviewed-by: Thiago Macieira --- src/widgets/graphicsview/qgraphicsscene.h | 1 - src/widgets/graphicsview/qgraphicssceneindex_p.h | 1 - src/widgets/kernel/qapplication.h | 1 - src/widgets/widgets/qsplitter.h | 1 - 4 files changed, 4 deletions(-) (limited to 'src/widgets') diff --git a/src/widgets/graphicsview/qgraphicsscene.h b/src/widgets/graphicsview/qgraphicsscene.h index d36a871533..e72ed99a7b 100644 --- a/src/widgets/graphicsview/qgraphicsscene.h +++ b/src/widgets/graphicsview/qgraphicsscene.h @@ -54,7 +54,6 @@ QT_REQUIRE_CONFIG(graphicsview); QT_BEGIN_NAMESPACE -template class QList; class QFocusEvent; class QFont; class QFontMetrics; diff --git a/src/widgets/graphicsview/qgraphicssceneindex_p.h b/src/widgets/graphicsview/qgraphicssceneindex_p.h index b494c52671..e13c2a3cd3 100644 --- a/src/widgets/graphicsview/qgraphicssceneindex_p.h +++ b/src/widgets/graphicsview/qgraphicssceneindex_p.h @@ -67,7 +67,6 @@ QT_BEGIN_NAMESPACE class QGraphicsSceneIndexPrivate; class QPointF; class QRectF; -template class QList; typedef bool (*QGraphicsSceneIndexIntersector)(const QGraphicsItem *item, const QRectF &exposeRect, Qt::ItemSelectionMode mode, const QTransform &deviceTransform, const void *data); diff --git a/src/widgets/kernel/qapplication.h b/src/widgets/kernel/qapplication.h index 27e743a28d..d7cc4489c4 100644 --- a/src/widgets/kernel/qapplication.h +++ b/src/widgets/kernel/qapplication.h @@ -58,7 +58,6 @@ class QDesktopWidget; class QStyle; class QEventLoop; class QIcon; -template class QList; class QLocale; class QPlatformNativeInterface; diff --git a/src/widgets/widgets/qsplitter.h b/src/widgets/widgets/qsplitter.h index ec980d9ee3..658914ae39 100644 --- a/src/widgets/widgets/qsplitter.h +++ b/src/widgets/widgets/qsplitter.h @@ -50,7 +50,6 @@ QT_BEGIN_NAMESPACE class QSplitterPrivate; class QTextStream; -template class QList; class QSplitterHandle; -- cgit v1.2.3 From ce2fc51914f809369d5096e7a0621229dd9eaef9 Mon Sep 17 00:00:00 2001 From: Michal Klocek Date: Mon, 30 Sep 2019 15:27:19 +0200 Subject: Add check for global share context for QOpenGLWidget initialize Fixes: QTBUG-78863 Change-Id: I678f66a2057fb9c98863e19eb09042306e72f68a Reviewed-by: Laszlo Agocs --- src/widgets/kernel/qopenglwidget.cpp | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) (limited to 'src/widgets') diff --git a/src/widgets/kernel/qopenglwidget.cpp b/src/widgets/kernel/qopenglwidget.cpp index 374ea53726..a88054a0d0 100644 --- a/src/widgets/kernel/qopenglwidget.cpp +++ b/src/widgets/kernel/qopenglwidget.cpp @@ -788,10 +788,12 @@ void QOpenGLWidgetPrivate::initialize() if (initialized) return; - // Get our toplevel's context with which we will share in order to make the - // texture usable by the underlying window's backingstore. + // If no global shared context get our toplevel's context with which we + // will share in order to make the texture usable by the underlying window's backingstore. QWidget *tlw = q->window(); - QOpenGLContext *shareContext = get(tlw)->shareContext(); + QOpenGLContext *shareContext = qt_gl_global_share_context(); + if (!shareContext) + shareContext = get(tlw)->shareContext(); // If shareContext is null, showing content on-screen will not work. // However, offscreen rendering and grabFramebuffer() will stay fully functional. -- cgit v1.2.3 From b6ce61f486a06ded273d518d871906f9a53ab7c1 Mon Sep 17 00:00:00 2001 From: Kari Hormi Date: Mon, 7 Oct 2019 16:21:33 +0300 Subject: Fix text not rendering properly after setAlignment call Sometimes when setAlignment is called, the text stops rendering correctly at some point. Adding relayoutDocument call to setAlignment fixes the problem. Fixes: QTBUG-78728 Change-Id: Iab1cf161f0c8d700804448733338c813b5bf9762 Reviewed-by: Ville Voutilainen --- src/widgets/widgets/qtextedit.cpp | 1 + 1 file changed, 1 insertion(+) (limited to 'src/widgets') diff --git a/src/widgets/widgets/qtextedit.cpp b/src/widgets/widgets/qtextedit.cpp index 0ae63f2dd5..2b3a46ae56 100644 --- a/src/widgets/widgets/qtextedit.cpp +++ b/src/widgets/widgets/qtextedit.cpp @@ -746,6 +746,7 @@ void QTextEdit::setAlignment(Qt::Alignment a) QTextCursor cursor = d->control->textCursor(); cursor.mergeBlockFormat(fmt); d->control->setTextCursor(cursor); + d->relayoutDocument(); } /*! -- cgit v1.2.3 From 00e8f044e1954ea47f1f0c5c5ff35fff97b732be Mon Sep 17 00:00:00 2001 From: Volker Hilsheimer Date: Tue, 8 Oct 2019 16:34:49 +0200 Subject: QWidget: document that a widget might only get a mouseDoubleClickEvent If two widgets are on top of each other, and the top widget disappears in response to a press or release that is followed by a double click, then the widget at the bottom only receives the double click event. This is a sequence of events that the application developer that choses to build such a UI has to take care of. Change-Id: I440efd2cac01631de8995abf9a9fb76815de8f9a Fixes: QTBUG-61173 Reviewed-by: Paul Wicking --- src/widgets/kernel/qwidget.cpp | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) (limited to 'src/widgets') diff --git a/src/widgets/kernel/qwidget.cpp b/src/widgets/kernel/qwidget.cpp index 6889c2e9e5..b70a03b311 100644 --- a/src/widgets/kernel/qwidget.cpp +++ b/src/widgets/kernel/qwidget.cpp @@ -9218,9 +9218,11 @@ void QWidget::mouseReleaseEvent(QMouseEvent *event) The default implementation calls mousePressEvent(). \note The widget will also receive mouse press and mouse release - events in addition to the double click event. It is up to the - developer to ensure that the application interprets these events - correctly. + events in addition to the double click event. And if another widget + that overlaps this widget disappears in response to press or + release events, then this widget will only receive the double click + event. It is up to the developer to ensure that the application + interprets these events correctly. \sa mousePressEvent(), mouseReleaseEvent(), mouseMoveEvent(), event(), QMouseEvent -- cgit v1.2.3 From 0e12c8b020d8bb54d214ecbab284429cc702e2d0 Mon Sep 17 00:00:00 2001 From: Volker Hilsheimer Date: Wed, 9 Oct 2019 12:40:10 +0200 Subject: Remove deprecated PE_IndicatorViewItemCheck and PE_FrameStatusBar They have been marked as deprecated since 5.13, and can be removed from Qt 6 codebase, which silences the respective compiler warnings. Change-Id: I3443c7bfa8db148b0b48957e2adc5eb131197faf Reviewed-by: Timur Pocheptsov --- src/widgets/doc/snippets/javastyle.cpp | 2 +- src/widgets/doc/src/widgets-and-layouts/styles.qdoc | 2 +- src/widgets/styles/qstyle.cpp | 1 - src/widgets/styles/qstyle.h | 6 ------ 4 files changed, 2 insertions(+), 9 deletions(-) (limited to 'src/widgets') diff --git a/src/widgets/doc/snippets/javastyle.cpp b/src/widgets/doc/snippets/javastyle.cpp index 8657d5ed29..de3143f753 100644 --- a/src/widgets/doc/snippets/javastyle.cpp +++ b/src/widgets/doc/snippets/javastyle.cpp @@ -2130,7 +2130,7 @@ void JavaStyle::drawPrimitive(PrimitiveElement element, painter->restore(); break; } - case PE_IndicatorViewItemCheck: { + case PE_IndicatorItemViewItemCheck: { break; } case PE_FrameWindow: { diff --git a/src/widgets/doc/src/widgets-and-layouts/styles.qdoc b/src/widgets/doc/src/widgets-and-layouts/styles.qdoc index 645da5bca2..faaf4e5479 100644 --- a/src/widgets/doc/src/widgets-and-layouts/styles.qdoc +++ b/src/widgets/doc/src/widgets-and-layouts/styles.qdoc @@ -1837,7 +1837,7 @@ item views keep the dimensions on individual sections. Also note that the delegates may use the style to paint decorations and frames around items. QItemDelegate, for instance, draws - \c PE_FrameFocusRect and \c PE_IndicatorViewItemCheck. + \c PE_FrameFocusRect and \c PE_IndicatorItemViewItemCheck. \image javastyle/header.png diff --git a/src/widgets/styles/qstyle.cpp b/src/widgets/styles/qstyle.cpp index 6cbed34c3a..ca81be1b2b 100644 --- a/src/widgets/styles/qstyle.cpp +++ b/src/widgets/styles/qstyle.cpp @@ -638,7 +638,6 @@ void QStyle::drawItemPixmap(QPainter *painter, const QRect &rect, int alignment, indicator or button bevel. \omitvalue PE_IndicatorViewItemCheck - \value PE_FrameStatusBar Obsolete. Use PE_FrameStatusBarItem instead. \value PE_PanelButtonCommand Button used to initiate an action, for example, a QPushButton. diff --git a/src/widgets/styles/qstyle.h b/src/widgets/styles/qstyle.h index ee234457f5..b51bcbe8d6 100644 --- a/src/widgets/styles/qstyle.h +++ b/src/widgets/styles/qstyle.h @@ -142,9 +142,6 @@ public: PE_FrameLineEdit, PE_FrameMenu, PE_FrameStatusBarItem, -#if QT_DEPRECATED_SINCE(5, 13) // ### Qt 6: remove - PE_FrameStatusBar Q_DECL_ENUMERATOR_DEPRECATED = PE_FrameStatusBarItem, -#endif PE_FrameTabWidget, PE_FrameWindow, PE_FrameButtonBevel, @@ -165,9 +162,6 @@ public: PE_IndicatorBranch, PE_IndicatorButtonDropDown, PE_IndicatorItemViewItemCheck, -#if QT_DEPRECATED_SINCE(5, 13) // ### Qt 6: remove - PE_IndicatorViewItemCheck Q_DECL_ENUMERATOR_DEPRECATED = PE_IndicatorItemViewItemCheck, -#endif PE_IndicatorCheckBox, PE_IndicatorDockWidgetResizeHandle, PE_IndicatorHeaderArrow, -- cgit v1.2.3 From e1fd6074935cd0be0df14d89eb0244fcbd1677cf Mon Sep 17 00:00:00 2001 From: Lars Knoll Date: Fri, 1 Feb 2019 11:50:05 +0100 Subject: Remove leftovers from QML1 QML1 is not supported anymore, remove the leftover hooks for it. Change-Id: I2900726714c5faea3523b2ebe39bb393364b3bfb Reviewed-by: Lars Knoll --- src/widgets/graphicsview/qgraphicsitem.cpp | 9 ++------- src/widgets/kernel/qwidget.cpp | 9 ++------- 2 files changed, 4 insertions(+), 14 deletions(-) (limited to 'src/widgets') diff --git a/src/widgets/graphicsview/qgraphicsitem.cpp b/src/widgets/graphicsview/qgraphicsitem.cpp index bb00db4c01..88baf8015a 100644 --- a/src/widgets/graphicsview/qgraphicsitem.cpp +++ b/src/widgets/graphicsview/qgraphicsitem.cpp @@ -1580,13 +1580,8 @@ QGraphicsItem::~QGraphicsItem() p->wasDeleted = true; if (p->declarativeData) { p->wasDeleted = true; // needed, so that destroying the declarative data does the right thing - if (static_cast(p->declarativeData)->ownedByQml1) { - if (QAbstractDeclarativeData::destroyed_qml1) - QAbstractDeclarativeData::destroyed_qml1(p->declarativeData, o); - } else { - if (QAbstractDeclarativeData::destroyed) - QAbstractDeclarativeData::destroyed(p->declarativeData, o); - } + if (QAbstractDeclarativeData::destroyed) + QAbstractDeclarativeData::destroyed(p->declarativeData, o); p->declarativeData = 0; p->wasDeleted = false; } diff --git a/src/widgets/kernel/qwidget.cpp b/src/widgets/kernel/qwidget.cpp index 6889c2e9e5..ea9299f36e 100644 --- a/src/widgets/kernel/qwidget.cpp +++ b/src/widgets/kernel/qwidget.cpp @@ -1513,13 +1513,8 @@ QWidget::~QWidget() if (d->declarativeData) { d->wasDeleted = true; // needed, so that destroying the declarative data does the right thing - if (static_cast(d->declarativeData)->ownedByQml1) { - if (QAbstractDeclarativeData::destroyed_qml1) - QAbstractDeclarativeData::destroyed_qml1(d->declarativeData, this); - } else { - if (QAbstractDeclarativeData::destroyed) - QAbstractDeclarativeData::destroyed(d->declarativeData, this); - } + if (QAbstractDeclarativeData::destroyed) + QAbstractDeclarativeData::destroyed(d->declarativeData, this); d->declarativeData = 0; // don't activate again in ~QObject d->wasDeleted = false; } -- cgit v1.2.3 From f7cb11d6f12f7bb353640637719292b95fd21438 Mon Sep 17 00:00:00 2001 From: Friedemann Kleint Date: Mon, 7 Oct 2019 13:59:13 +0200 Subject: QWidget: Answer question raised in fixme comment MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Add a comment for fixme comment added in f1268d137ea7839b320c84314d0c2265f5a629ba. Change-Id: I08cd104442b13925be2aa5a48e64e391c9903099 Reviewed-by: Tor Arne Vestbø --- src/widgets/kernel/qwidget.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/widgets') diff --git a/src/widgets/kernel/qwidget.cpp b/src/widgets/kernel/qwidget.cpp index b70a03b311..588bed0366 100644 --- a/src/widgets/kernel/qwidget.cpp +++ b/src/widgets/kernel/qwidget.cpp @@ -7669,7 +7669,7 @@ void QWidget::show() else if (defaultState == Qt::WindowMaximized) showMaximized(); else - setVisible(true); // FIXME: Why not showNormal(), like QWindow::show()? + setVisible(true); // Don't call showNormal() as not to clobber Qt::Window(Max/Min)imized } /*! \internal -- cgit v1.2.3 From f1dd6addda908185f497d299d706b88977dea858 Mon Sep 17 00:00:00 2001 From: Shawn Rutledge Date: Wed, 2 Oct 2019 12:19:11 +0200 Subject: Make QTextBlockFormat::MarkerType an enum class This came up during API review. Change-Id: I9198e1eb96db0c21e46a226a032919bb62d3ca66 Reviewed-by: Giuseppe D'Angelo --- src/widgets/widgets/qtextedit.cpp | 2 +- src/widgets/widgets/qwidgettextcontrol.cpp | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) (limited to 'src/widgets') diff --git a/src/widgets/widgets/qtextedit.cpp b/src/widgets/widgets/qtextedit.cpp index 0702603648..dd2ea3f18f 100644 --- a/src/widgets/widgets/qtextedit.cpp +++ b/src/widgets/widgets/qtextedit.cpp @@ -237,7 +237,7 @@ void QTextEditPrivate::_q_hoveredBlockWithMarkerChanged(const QTextBlock &block) Qt::CursorShape cursor = cursorToRestoreAfterHover; if (block.isValid() && !q->isReadOnly()) { QTextBlockFormat::MarkerType marker = block.blockFormat().marker(); - if (marker != QTextBlockFormat::NoMarker) { + if (marker != QTextBlockFormat::MarkerType::NoMarker) { if (viewport->cursor().shape() != Qt::PointingHandCursor) cursorToRestoreAfterHover = viewport->cursor().shape(); cursor = Qt::PointingHandCursor; diff --git a/src/widgets/widgets/qwidgettextcontrol.cpp b/src/widgets/widgets/qwidgettextcontrol.cpp index fdbaf29dd8..094c59a0c9 100644 --- a/src/widgets/widgets/qwidgettextcontrol.cpp +++ b/src/widgets/widgets/qwidgettextcontrol.cpp @@ -1810,11 +1810,11 @@ void QWidgetTextControlPrivate::mouseReleaseEvent(QEvent *e, Qt::MouseButton but if (markerBlock == blockWithMarkerUnderMouse) { auto fmt = blockWithMarkerUnderMouse.blockFormat(); switch (fmt.marker()) { - case QTextBlockFormat::Unchecked : - fmt.setMarker(QTextBlockFormat::Checked); + case QTextBlockFormat::MarkerType::Unchecked : + fmt.setMarker(QTextBlockFormat::MarkerType::Checked); break; - case QTextBlockFormat::Checked: - fmt.setMarker(QTextBlockFormat::Unchecked); + case QTextBlockFormat::MarkerType::Checked: + fmt.setMarker(QTextBlockFormat::MarkerType::Unchecked); break; default: break; -- cgit v1.2.3 From 65fcd8524da628c99e8cd28f983f0c17fbe157f0 Mon Sep 17 00:00:00 2001 From: Volker Hilsheimer Date: Tue, 8 Oct 2019 16:25:08 +0200 Subject: QAbstractScrollArea: when used as a popup, apply regular popup behavior MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit QWidget::mousePressEvent is documented to implement the closing of popups if the widget is a popup. QAbstractScrollArea is one of the QWidget subclasses that might be used as a popup as well, so instead of just ignoring mousePressEvents, pass the event on to the QWidget implementation for regular popup handling. Change-Id: I05f77a334945f3c167f729f30bc022599230379b Fixes: QTBUG-60885 Reviewed-by: Tor Arne Vestbø Reviewed-by: Paul Olav Tvete --- src/widgets/widgets/qabstractscrollarea.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'src/widgets') diff --git a/src/widgets/widgets/qabstractscrollarea.cpp b/src/widgets/widgets/qabstractscrollarea.cpp index b295e66574..d2372a7be9 100644 --- a/src/widgets/widgets/qabstractscrollarea.cpp +++ b/src/widgets/widgets/qabstractscrollarea.cpp @@ -1144,11 +1144,14 @@ void QAbstractScrollArea::paintEvent(QPaintEvent*) mouse press events for the viewport() widget. The event is passed in \a e. + The default implementation calls QWidget::mousePressEvent() for + default popup handling. + \sa QWidget::mousePressEvent() */ void QAbstractScrollArea::mousePressEvent(QMouseEvent *e) { - e->ignore(); + QWidget::mousePressEvent(e); } /*! -- cgit v1.2.3 From 81a790969395feff73fa600908822765e97424e5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Morten=20Johan=20S=C3=B8rvig?= Date: Thu, 3 Oct 2019 15:04:16 +0200 Subject: Fusion Style: Use high-dpi pixmaps Pass the QWindow as context to QIcon::pixmap(), which enables it to return high-dpi pixmaps when needed. Fixes: QTBUG-74100 Change-Id: I4556f0a98df8b6ba65376778379a03eb8c470d00 Reviewed-by: Friedemann Kleint --- src/widgets/styles/qfusionstyle.cpp | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) (limited to 'src/widgets') diff --git a/src/widgets/styles/qfusionstyle.cpp b/src/widgets/styles/qfusionstyle.cpp index ba2b6b0ed9..b58dc1660a 100644 --- a/src/widgets/styles/qfusionstyle.cpp +++ b/src/widgets/styles/qfusionstyle.cpp @@ -88,6 +88,7 @@ #include #include #include +#include QT_BEGIN_NAMESPACE @@ -364,6 +365,11 @@ static void qt_fusion_draw_mdibutton(QPainter *painter, const QStyleOptionTitleB painter->drawPoint(tmp.right() , tmp.bottom() - 1); } +static QWindow *qt_getWindow(const QWidget *widget) +{ + return widget ? QWidgetPrivate::get(widget)->windowHandle(QWidgetPrivate::WindowHandleMode::Closest) : nullptr; +} + /* \internal */ @@ -995,7 +1001,7 @@ void QFusionStyle::drawPrimitive(PrimitiveElement elem, d->tabBarcloseButtonIcon = proxy()->standardIcon(SP_DialogCloseButton, option, widget); if ((option->state & State_Enabled) && (option->state & State_MouseOver)) proxy()->drawPrimitive(PE_PanelButtonCommand, option, painter, widget); - QPixmap pixmap = d->tabBarcloseButtonIcon.pixmap(QSize(16, 16), QIcon::Normal, QIcon::On); + QPixmap pixmap = d->tabBarcloseButtonIcon.pixmap(qt_getWindow(widget), QSize(16, 16), QIcon::Normal, QIcon::On); proxy()->drawItemPixmap(painter, option->rect, Qt::AlignCenter, pixmap); } break; @@ -1035,7 +1041,7 @@ void QFusionStyle::drawControl(ControlElement element, const QStyleOption *optio if (!cb->currentIcon.isNull()) { QIcon::Mode mode = cb->state & State_Enabled ? QIcon::Normal : QIcon::Disabled; - QPixmap pixmap = cb->currentIcon.pixmap(cb->iconSize, mode); + QPixmap pixmap = cb->currentIcon.pixmap(qt_getWindow(widget), cb->iconSize, mode); QRect iconRect(editRect); iconRect.setWidth(cb->iconSize.width() + 4); iconRect = alignedRect(cb->direction, @@ -1647,9 +1653,9 @@ void QFusionStyle::drawControl(ControlElement element, const QStyleOption *optio iconSize = combo->iconSize(); #endif if (checked) - pixmap = menuItem->icon.pixmap(iconSize, mode, QIcon::On); + pixmap = menuItem->icon.pixmap(qt_getWindow(widget), iconSize, mode, QIcon::On); else - pixmap = menuItem->icon.pixmap(iconSize, mode); + pixmap = menuItem->icon.pixmap(qt_getWindow(widget), iconSize, mode); const int pixw = pixmap.width() / pixmap.devicePixelRatio(); const int pixh = pixmap.height() / pixmap.devicePixelRatio(); @@ -1783,7 +1789,7 @@ void QFusionStyle::drawControl(ControlElement element, const QStyleOption *optio if (button->state & State_On) state = QIcon::On; - QPixmap pixmap = button->icon.pixmap(button->iconSize, mode, state); + QPixmap pixmap = button->icon.pixmap(qt_getWindow(widget), button->iconSize, mode, state); int w = pixmap.width() / pixmap.devicePixelRatio(); int h = pixmap.height() / pixmap.devicePixelRatio(); -- cgit v1.2.3 From 1748dc3e2d2367f9f01666212a22e6b1dde5dc89 Mon Sep 17 00:00:00 2001 From: Volker Hilsheimer Date: Mon, 7 Oct 2019 16:09:37 +0200 Subject: QGroupBox: always disable children in a checkable, unchecked groupbox The childEvent handler sets the enabled property of children as they are added to the groupbox, but applications might later enable children and check/uncheck the groupbox's checkbox in undefined order. In that case, we would end up with enabled children inside a conceptually disabled groupbox (the groupbox's checkbox represents the logical "disabled" state), which breaks documented QWidget::enabled rules. To make sure that all children are disabled as per the state of the groupbox, we need to run that logic once the UI has been set up, and before it becomes visible. This is what polishing is for, so listen for that event in addition and handle it the same way as adding (which duplicates things, but keeps existing code that might depend on things being updated as they are added working). Adds the case to the existing enabledChildPropagation test case. [ChangeLog][QWidget][QGroupBox] Always disable children of a checkable, unchecked group box before showing. Change-Id: I978bd27b6f1a3f54ec745faeea529a98d0d93619 Fixes: QTBUG-25938 Reviewed-by: Shawn Rutledge --- src/widgets/widgets/qgroupbox.cpp | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) (limited to 'src/widgets') diff --git a/src/widgets/widgets/qgroupbox.cpp b/src/widgets/widgets/qgroupbox.cpp index 69eac1ebf7..eec794562a 100644 --- a/src/widgets/widgets/qgroupbox.cpp +++ b/src/widgets/widgets/qgroupbox.cpp @@ -389,9 +389,13 @@ bool QGroupBox::event(QEvent *e) void QGroupBox::childEvent(QChildEvent *c) { Q_D(QGroupBox); - if (c->type() != QEvent::ChildAdded || !c->child()->isWidgetType()) + /* + Children might have been enabled after being added to the group box, in which case + the childEvent handler ran too early, and we need to disabled children again. + */ + if (!(c->added() || c->polished()) || !c->child()->isWidgetType()) return; - QWidget *w = (QWidget*)c->child(); + QWidget *w = static_cast(c->child()); if (w->isWindow()) return; if (d->checkable) { -- cgit v1.2.3