From 61b71ffb3b2b34aea67306c973ee751335733433 Mon Sep 17 00:00:00 2001 From: Wladimir Leuschner Date: Tue, 9 Apr 2024 10:44:22 +0200 Subject: QComboBox: Revert recreation of ComboBox Container on style change In commit 9da8d67b3bca1d40ae221a9c6be218fe57759724 a recreation of the ComboBox Container was introduced, since QWindows11Style depends on WA_TranslucentBackground flag, whereas the other styles don't set this flag. This leads to the destruction of user supplied views we don't own. Fixes: QTBUG-124191 Pick-to: 6.7 Change-Id: I4a693f612ddc299696b9de0d87c94d88c04d9b39 Reviewed-by: Volker Hilsheimer --- src/widgets/widgets/qcombobox.cpp | 18 +----------------- 1 file changed, 1 insertion(+), 17 deletions(-) (limited to 'src/widgets/widgets/qcombobox.cpp') diff --git a/src/widgets/widgets/qcombobox.cpp b/src/widgets/widgets/qcombobox.cpp index 06de5566ff..1fe9a8d7be 100644 --- a/src/widgets/widgets/qcombobox.cpp +++ b/src/widgets/widgets/qcombobox.cpp @@ -3003,24 +3003,8 @@ void QComboBox::changeEvent(QEvent *e) Q_D(QComboBox); switch (e->type()) { case QEvent::StyleChange: - 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 + if (d->container) d->container->updateStyleSettings(); - } d->updateDelegate(); #ifdef Q_OS_MAC -- cgit v1.2.3