From ed68a6ba41012ea56f30b3a4db3d8a3431c04c75 Mon Sep 17 00:00:00 2001 From: Christian Ehrlicher Date: Wed, 10 Jan 2024 20:37:19 +0100 Subject: [PATCH] QComboBox: ignore hidden items when calculating popup size The popup size depends on the max visible items property. But the loop did not ignore the hidden items which results in fewer items in the popup than allowed. Fixes: QTBUG-120574 Pick-to: 6.5 Change-Id: Ic3c503a5272d6839aee158740e096405ca8887d6 Reviewed-by: Axel Spoerl (cherry picked from commit 742be5254c9919e8c743b8b489c054d778ee4850) Reviewed-by: Qt Cherry-pick Bot (cherry picked from commit 8e6b46fa65968664159d3aa619c2ed9d53f39ceb) --- src/widgets/widgets/qcombobox.cpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/widgets/widgets/qcombobox.cpp b/src/widgets/widgets/qcombobox.cpp index 95ead3ca59f..c36f41ae490 100644 --- a/src/widgets/widgets/qcombobox.cpp +++ b/src/widgets/widgets/qcombobox.cpp @@ -2644,6 +2644,7 @@ void QComboBox::showPopup() QPoint above = mapToGlobal(listRect.topLeft()); int aboveHeight = above.y() - screen.y(); bool boundToScreen = !window()->testAttribute(Qt::WA_DontShowOnScreen); + const auto listView = qobject_cast(d->viewContainer()->itemView()); { int listHeight = 0; @@ -2658,6 +2659,8 @@ void QComboBox::showPopup() while (!toCheck.isEmpty()) { QModelIndex parent = toCheck.pop(); for (int i = 0, end = d->model->rowCount(parent); i < end; ++i) { + if (listView && listView->isRowHidden(i)) + continue; QModelIndex idx = d->model->index(i, d->modelColumn, parent); if (!idx.isValid()) continue;