From 4ebc2cf74e557b65a8ce1dc518ca92f399ce89e8 Mon Sep 17 00:00:00 2001 From: Daniel Teske Date: Wed, 14 Dec 2016 10:24:21 +0100 Subject: macOS QComboBox: Don't show scrollers if they aren't needed Task-number: QTBUG-13925 Task-number: QTBUG-18788 Change-Id: Id155ea26824e1cb470cc6174704436d99fb7ac87 Reviewed-by: Gabriel de Dietrich --- src/widgets/widgets/qcombobox.cpp | 13 +++++++++++++ src/widgets/widgets/qcombobox_p.h | 1 + 2 files changed, 14 insertions(+) (limited to 'src') diff --git a/src/widgets/widgets/qcombobox.cpp b/src/widgets/widgets/qcombobox.cpp index 21b3eab0ad..a8a54d8d67 100644 --- a/src/widgets/widgets/qcombobox.cpp +++ b/src/widgets/widgets/qcombobox.cpp @@ -490,6 +490,14 @@ void QComboBoxPrivateContainer::scrollItemView(int action) #endif } +void QComboBoxPrivateContainer::hideScrollers() +{ + if (top) + top->hide(); + if (bottom) + bottom->hide(); +} + /* Hides or shows the scrollers when we emulate a popupmenu */ @@ -2731,6 +2739,11 @@ void QComboBox::showPopup() if (needHorizontalScrollBar) { listRect.adjust(0, 0, 0, sb->height()); } + + // Hide the scrollers here, so that the listrect gets the full height of the container + // If the scrollers are truly needed, the later call to container->updateScrollers() + // will make them visible again. + container->hideScrollers(); container->setGeometry(listRect); #ifndef Q_OS_MAC diff --git a/src/widgets/widgets/qcombobox_p.h b/src/widgets/widgets/qcombobox_p.h index 2340f06954..8d3b46a950 100644 --- a/src/widgets/widgets/qcombobox_p.h +++ b/src/widgets/widgets/qcombobox_p.h @@ -231,6 +231,7 @@ public: public Q_SLOTS: void scrollItemView(int action); + void hideScrollers(); void updateScrollers(); void viewDestroyed(); -- cgit v1.2.3