diff options
author | Wladimir Leuschner <wladimir.leuschner@qt.io> | 2023-06-01 14:45:47 +0300 |
---|---|---|
committer | Wladimir Leuschner <wladimir.leuschner@qt.io> | 2023-10-27 16:32:55 +0000 |
commit | 9da8d67b3bca1d40ae221a9c6be218fe57759724 (patch) | |
tree | 88f397ff5a3ee2fe2ae1dccd9013bb48e7956c7f /src/widgets/widgets/qcombobox.cpp | |
parent | 64db4042d4090078690829816eabeecce8ee5098 (diff) |
Introduce Windows 11 styled ComboBox in QWindows11Style
QComboBox is adapted to use the WinUI3 style.
Task-number: QTBUG-113513
Change-Id: I300157a7ce9162be73ccd4acfc50b12f7166dc2d
Reviewed-by: Oliver Wolff <oliver.wolff@qt.io>
Diffstat (limited to 'src/widgets/widgets/qcombobox.cpp')
-rw-r--r-- | src/widgets/widgets/qcombobox.cpp | 23 |
1 files changed, 21 insertions, 2 deletions
diff --git a/src/widgets/widgets/qcombobox.cpp b/src/widgets/widgets/qcombobox.cpp index b7a084364b..937076a7b5 100644 --- a/src/widgets/widgets/qcombobox.cpp +++ b/src/widgets/widgets/qcombobox.cpp @@ -761,7 +761,9 @@ bool QComboBoxPrivateContainer::eventFilter(QObject *o, QEvent *e) QModelIndex indexUnderMouse = view->indexAt(m->position().toPoint()); if (indexUnderMouse.isValid() && !QComboBoxDelegate::isSeparator(indexUnderMouse)) { - view->setCurrentIndex(indexUnderMouse); + // Request for comments: To show selected item with AccentColor bar indicator and hovered + // items in the flyout, the next line needs to be removed. + //view->setCurrentIndex(indexUnderMouse); } } break; @@ -2969,9 +2971,26 @@ void QComboBox::changeEvent(QEvent *e) Q_D(QComboBox); switch (e->type()) { case QEvent::StyleChange: - if (d->container) + if (d->container) { +// If on Windows, force recreation of ComboBox container, since +// windows11 style depends on WA_TranslucentBackground +#ifdef Q_OS_WIN + auto delegate = itemDelegate(); + d->container->deleteLater(); + // d->container needs to be set explicitly to nullptr + // since QComboBoxPrivate::viewContainer() only + // creates a new QComboBoxPrivateContainer when + // d->container has the value of nullptr + d->container = nullptr; + d->container = d->viewContainer(); + delegate->setParent(d->container); + setItemDelegate(delegate); + +#endif d->container->updateStyleSettings(); + } d->updateDelegate(); + #ifdef Q_OS_MAC case QEvent::MacSizeChange: #endif |