Uploaded image for project: 'Qt'
  1. Qt
  2. QTBUG-70395

QComboBox up and down arrow scroll controls does not disappear once they are shown for the first time

    XMLWordPrintable

Details

    • Bug
    • Resolution: Unresolved
    • P2: Important
    • None
    • 5.9.5
    • GUI: Text handling
    • None
    • Ubuntu 18.04.1 LTS
    • Linux/X11

    Description

      QComboBox up and down arrow scroll controls does not disappear once they are shown for the first time. I made simple example to show the bug. For first time, short list is good. When I set a lot of items to my combobox up and down arrow controls appear. When I set back just few items again, up and down scrolling buttons still appear and visual is broken.

      MainWindow::MainWindow(QWidget *parent) :
          QMainWindow(parent),
          ui(new Ui::MainWindow)
      {
          ui->setupUi(this);
      }
      
      MainWindow::~MainWindow()
      {
          delete ui;
      }
      
      void MainWindow::on_pushButtonLongList_clicked()
      {
          int count = 100;
      
          ui->comboBox->clear();
          for (int i = 1; i < count; ++i) {
              ui->comboBox->insertItem(ui->comboBox->count(),"Value"+QString::number(i));
          }
      }
      
      void MainWindow::on_pushButtonShortList_clicked()
      {
          int count = 4;
          ui->comboBox->clear();
      
          for (int i = 1; i < count; ++i) {
              ui->comboBox->insertItem(ui->comboBox->count(),"Value"+QString::number(i));
          }
      }
      

      Results can be seen on screenshot bellow. When I use:

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

      Then scrollbar also does not hide even on short list in combobox. And btw, is there any way to hide these up and down scrolling buttons?

      Attachments

        1. combobox-bug.jpeg
          229 kB
          Jan Hetych
        2. image-2021-09-07-14-14-59-601.png
          8 kB
          Rick
        No reviews matched the request. Check your Options in the drop-down menu of this sections header.

        Activity

          People

            esabraha Eskil Abrahamsen Blomfeldt
            honzik1 Jan Hetych
            Votes:
            1 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:

              Gerrit Reviews

                There are no open Gerrit changes