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

Glitches when scrolling items in a QComboBox and QScroller

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Unresolved
    • Icon: P2: Important P2: Important
    • None
    • 6.10.0
    • None
    • Android
    • 2025wk38s2QtforAndroid

      After QTBUG-127495 and QTBUG-128794 were fixed, now two new issues have appeared that were not present before:

      1. I'm using scrolling for the QComboBox like this:
        QScroller::grabGesture(comboBox->view()->viewport(), QScroller::LeftMouseButtonGesture);
        But now, when the scrollbar is all the way at the top and I start dragging downward, the items glitch heavily as they are being scrolled. It visually distorts the list, making the items look smeared or blurry while moving.
      1. When I select an item from the list, it disappears as expected, but the selected item does not appear in the QComboBox – it looks like the selection didn’t happen, at least visually. The dropdown closes, but the combobox doesn’t update to show the chosen item.

                 +1 on Galaxy_Nexus_API_30: The first appearance of the elements is slow, at first it seems like it's frozen, but after a while if I press it again it opens properly.

      The code what I used:

      #include <QApplication> 
      #include <QComboBox> 
      #include <QPainter> 
      #include <QStyleOptionComboBox> 
      #include <QWidget> 
      #include <QVBoxLayout> 
      #include <QTimer> 
      #include <QScroller> 
      #include <QAbstractItemView>
      
      class CustomComboBox : public QComboBox 
      {     
          Q_OBJECT
      public:     
          CustomComboBox(QWidget *parent = nullptr) : QComboBox(parent)     
          {         
              setCurrentIndex(-1);     
          } 
      protected:     
          void paintEvent(QPaintEvent *event) override 
          {         
              QComboBox::paintEvent(event);        
              if (currentIndex() == -1)         
              {
                  QStyleOptionComboBox opt;             
                  initStyleOption(&opt);            
                  QPainter painter(this);             
                  QFont italicFont = painter.font();
                  italicFont.setItalic(true);             
                  painter.setFont(italicFont);            
                  painter.setPen(Qt::gray);
                  painter.drawText(rect().adjusted(4, 0, -4, 0), Qt::AlignVCenter | 
                  Qt::AlignLeft, placeholderText);         
               }     
           }
      
      public:     
      void setPlaceholderText(const QString &text) 
      {         
          placeholderText = text;         
          update();     
      }
      
      private:     
      QString placeholderText; 
      };
      
      int main(int argc, char *argv[]) 
      {     
          QApplication app(argc, argv);    
          QWidget window;    
          CustomComboBox *comboBox = new CustomComboBox;    
          comboBox->addItems( {"Dungeon Worlds","DnD","Cyberpunk","Call of Cuthulu","ODnD","Dungeon Worlds2","DnD2","Cyberpunk2","Call of Cuthulu2","ODnD2"} );
      
      comboBox->setItemIcon(0,QIcon(":/RES/dungeonworldlogomini.png"));     
      comboBox->setItemIcon(1,QIcon(":/RES/dndlogomini.png"));     
      comboBox->setItemIcon(2,QIcon(":/RES/cyberpunklogomini.png"));     
      comboBox->setItemIcon(3,QIcon(":/RES/callofcuthululogomini.png"));     
      comboBox->setItemIcon(4,QIcon(":/RES/odndlogomini.png"));     
      comboBox->setItemIcon(5,QIcon(":/RES/dungeonworldlogomini.png"));     
      comboBox->setItemIcon(6,QIcon(":/RES/dndlogomini.png"));     
      comboBox->setItemIcon(7,QIcon(":/RES/cyberpunklogomini.png"));     
      comboBox->setItemIcon(8,QIcon(":/RES/callofcuthululogomini.png"));     
      comboBox->setItemIcon(9,QIcon(":/RES/odndlogomini.png"));    
      
      comboBox->setMaxVisibleItems(5);     
      comboBox->setPlaceholderText("Choose one item...");     
      comboBox->setStyleSheet("combobox-popup:0;");     
      QScroller::grabGesture(comboBox->view()>viewport(),QScroller::LeftMouseButtonGesture);     comboBox>view()>setVerticalScrollMode(QAbstractItemView::ScrollPerPixel);     comboBox>view()>setVerticalScrollBarPolicy(Qt::ScrollBarAsNeeded);     comboBox>view()>setAutoScroll(false);     
      comboBox>setCurrentIndex(-1);     
      
      comboBox>setIconSize(QSize(30,30));    
      
      QVBoxLayout *layout = new QVBoxLayout(&window);     
      layout->addStretch();     
      layout->addWidget(comboBox);     
      layout->addStretch();    
      
      window.show();    
      return app.exec(); 
      }
      
      #include "main.moc" 
      

       

        No reviews matched the request. Check your Options in the drop-down menu of this sections header.

            assam Assam Boudjelthia
            assam Assam Boudjelthia
            Votes:
            1 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated:

                There are no open Gerrit changes