Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

Vertical scroll bar in QComboBox



  • Hi all,

    I have a huge QComboBox (more than 2000 items) and Qt display it with tiny arrows on top and bottom like this:
    scrollBarBad.png

    But the scrolling is too slow, I need the classic vertical scrollbar like this (picked from this post:
    alt text

    How is it possible ?
    Thanks in advance

    Arnaud



  • @duarna
    You're not going to like this, but you simply should not populate a combobox for the user with 2000 items, it is not manageable! If you really have this many you should choose a different UI interface, e.g. use a QCompleter. Then you won't have this issue.....


  • Lifetime Qt Champion

    Hi
    As @JonB says, 2000 items in combobox is not a good experience for the end user.
    Its hard to navigate.

    Anyway, you can try
    ui->comboBox->view()->setVerticalScrollBarPolicy(Qt::ScrollBarAsNeeded);

    which gives me a scrollbar also on linux that normally only has the up/down arrows using XFCE WM.
    alt text



  • I had same problem on Windows when filling a combobox with almost 4000 lines (ICD10 diagnoses for a healthcare app), it works but you have to use the "classic" vertical scrollbar.
    On Windows this means you cannot use Fusion style, instead use the VistaStyle for the combobox.



  • Thank you all,

    Indeed QCompleter is the best alternative. However

    ui->comboBox->view()->setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOn);
    

    is the solution I was looking for.


Log in to reply