From 707b64bece4b5639a6bf5f2f51bd00690b77bead Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Morten=20Johan=20S=C3=B8rvig?= Date: Fri, 21 Aug 2020 16:20:31 +0200 Subject: Display combobox popup on the correct screen MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Display QCompoBox popups on the correct screen, also when the parent window spans multiple screens. In this case, QWidget::screen() will return the main screen for the window, which will not necessarily be the screen at the combobox popup position. Change-Id: Ib8a8163a757f7b849883b833fbde27a1e01af49a Reviewed-by: Tor Arne Vestbø --- src/widgets/widgets/qcombobox.cpp | 8 ++++---- src/widgets/widgets/qcombobox_p.h | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) (limited to 'src/widgets/widgets') diff --git a/src/widgets/widgets/qcombobox.cpp b/src/widgets/widgets/qcombobox.cpp index cf1d4a60fb..57a0834698 100644 --- a/src/widgets/widgets/qcombobox.cpp +++ b/src/widgets/widgets/qcombobox.cpp @@ -319,12 +319,12 @@ void QComboBoxPrivate::trySetValidIndex() setCurrentIndex(QModelIndex()); } -QRect QComboBoxPrivate::popupGeometry() const +QRect QComboBoxPrivate::popupGeometry(const QPoint &globalPosition) const { Q_Q(const QComboBox); return QStylePrivate::useFullScreenForPopup() - ? QWidgetPrivate::screenGeometry(q) - : QWidgetPrivate::availableScreenGeometry(q); + ? QWidgetPrivate::screenGeometry(q, globalPosition) + : QWidgetPrivate::availableScreenGeometry(q, globalPosition); } bool QComboBoxPrivate::updateHoverControl(const QPoint &pos) @@ -2612,7 +2612,7 @@ void QComboBox::showPopup() QComboBoxPrivateContainer* container = d->viewContainer(); QRect listRect(style->subControlRect(QStyle::CC_ComboBox, &opt, QStyle::SC_ComboBoxListBoxPopup, this)); - QRect screen = d->popupGeometry(); + QRect screen = d->popupGeometry(mapToGlobal(listRect.topLeft())); QPoint below = mapToGlobal(listRect.bottomLeft()); int belowHeight = screen.bottom() - below.y(); diff --git a/src/widgets/widgets/qcombobox_p.h b/src/widgets/widgets/qcombobox_p.h index bff6126d3e..b3adb4be69 100644 --- a/src/widgets/widgets/qcombobox_p.h +++ b/src/widgets/widgets/qcombobox_p.h @@ -371,7 +371,7 @@ public: void updateArrow(QStyle::StateFlag state); bool updateHoverControl(const QPoint &pos); void trySetValidIndex(); - QRect popupGeometry() const; + QRect popupGeometry(const QPoint &globalPos) const; QStyle::SubControl newHoverControl(const QPoint &pos); int computeWidthHint() const; QSize recomputeSizeHint(QSize &sh) const; -- cgit v1.2.3