How to size QComboBox popup height to the count of items
-
Re: Dynamically fit QComboBox popup height to the (dynamically changing) count of items
is there no definitive answer to this? my "dropdown" always has a scroll bar when it doesn't need to:
How do i tell it to resize just enough such that there's no scroll bar?
-
@vmanso said in How to size QComboBox popup height to the count of items:
maxVisibleItems
that was it! thanks so much!
-
@davecotter said in How to size QComboBox popup height to the count of items:
my "dropdown" always has a scroll bar when it doesn't need to
Do you mean there is nothing below "kJams 2 (Upgrade from Lite)" to scroll to?
-
no i mean there are a few more items, and there's no reason not to just show them by making the little "window" bigger, without needing a scroll bar
-
@davecotter
I happened to look at sizing ofQComboBox
dropdown just a few days ago (https://forum.qt.io/topic/105012/qcombobox-specify-width-less-than-content, I'm just going to put some code in there). It turns out it isQComboBox::view()
is what you need to fiddle with to adjust dropdown size. I was usingQComboBox::view()::setMinimumWidth()
for width, you will presumably want something withQComboBox::view()::setMinimumHeight()
, or something which sets its size policy to fit instead of scroll if that is available (QSizePolicy
??). -
@vmanso said in How to size QComboBox popup height to the count of items:
maxVisibleItems
Beware, the documentation of the function warns about some caveats to take into account for non-editable combo boxes on some platforms.
-
@vmanso said in How to size QComboBox popup height to the count of items:
maxVisibleItems
that was it! thanks so much!