Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Vertical scroll bar in QComboBox

Vertical scroll bar in QComboBox

Scheduled Pinned Locked Moved Solved General and Desktop
5 Posts 4 Posters 3.8k Views 2 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • D Offline
    D Offline
    duarna
    wrote on last edited by
    #1

    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

    JonBJ 1 Reply Last reply
    0
    • D duarna

      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

      JonBJ Offline
      JonBJ Offline
      JonB
      wrote on last edited by JonB
      #2

      @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.....

      1 Reply Last reply
      3
      • mrjjM Offline
        mrjjM Offline
        mrjj
        Lifetime Qt Champion
        wrote on last edited by
        #3

        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

        1 Reply Last reply
        3
        • hskoglundH Offline
          hskoglundH Offline
          hskoglund
          wrote on last edited by
          #4

          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.

          1 Reply Last reply
          2
          • D Offline
            D Offline
            duarna
            wrote on last edited by
            #5

            Thank you all,

            Indeed QCompleter is the best alternative. However

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

            is the solution I was looking for.

            1 Reply Last reply
            1

            • Login

            • Login or register to search.
            • First post
              Last post
            0
            • Categories
            • Recent
            • Tags
            • Popular
            • Users
            • Groups
            • Search
            • Get Qt Extensions
            • Unsolved