From df0b661bfc015bfe3eaeed3e811d63c91929e61c Mon Sep 17 00:00:00 2001 From: Axel Spoerl Date: Wed, 22 Mar 2023 11:09:41 +0100 Subject: [PATCH] Explicitly propagate screen to QComboBoxListView constructor MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit QComboBoxListView is constructed without a parent. It therefore inherits the current screen, which normally is the screen on which the related QComboBox is located. With two identical screens in Windows, that can lead to the popup showing on the wrong screen. The issue occurs, when the other screen is found before the right one. This patch calls setScreen() in the constructor, to explicitly inherit the screen from the combobox, if a valid pointer is passed. Fixes: QTBUG-106099 Pick-to: 6.5 6.2 5.15 Change-Id: Ic6679cfd59291092294d2cc75632a5485c2529b7 Reviewed-by: Jan Arve Sæther --- src/widgets/widgets/qcombobox_p.h | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/widgets/widgets/qcombobox_p.h b/src/widgets/widgets/qcombobox_p.h index 8e686ac79a8..18fcc071461 100644 --- a/src/widgets/widgets/qcombobox_p.h +++ b/src/widgets/widgets/qcombobox_p.h @@ -49,7 +49,11 @@ class QComboBoxListView : public QListView { Q_OBJECT public: - QComboBoxListView(QComboBox *cmb = nullptr) : combo(cmb) {} + QComboBoxListView(QComboBox *cmb = nullptr) : combo(cmb) + { + if (cmb) + setScreen(cmb->screen()); + } protected: void resizeEvent(QResizeEvent *event) override