Important: Please read the Qt Code of Conduct -

Scrolling combobox after it's been unfolded - is it possible?

  • Imagine a QComboBox with n items visible on screen when it's dropped down (unfolded). The default behavior is that the current item is topmost, followed by next n-1 items (provided there are are enough items after the current one, of course).
    What I want is to scroll a combobox so that the current item is at the center of the list - with n/2 items before it and n/2-1 items after it being visible on screen. Is it possible?

  • Lifetime Qt Champion


    From an educate guess: yes. You can create your own item view and model to set on the QComboBox so implementing such a behavior should be doable. However you are probably going to violate some user interface guidelines doing that which may also destabilize your user base.

  • That might be a diversion from the usual combo box behavior, but it will save my users a few clicks for an action that they perform most often.

    I can probably manipulate the combobox model, but how do I know it's been expanded? What event should I catch?

  • Lifetime Qt Champion

    It'll be more of a view problem where you can catch the show event and the use of a proxy filter to rearrange your model data.

Log in to reply