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. Problem with scroll in Qlistwidget
QtWS25 Last Chance

Problem with scroll in Qlistwidget

Scheduled Pinned Locked Moved General and Desktop
6 Posts 4 Posters 4.1k Views
  • 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.
  • M Offline
    M Offline
    mini.oxford
    wrote on last edited by
    #1

    I have problem with Scroll in QlistWidget. I couldn't change scroll speed. I used:
    @scrol->setPageStep(80);
    scrol->setSingleStep(80);@
    This scroll:
    @scrol=ui->listwidget->verticalScrollBar();@

    These methods doesn't work and speed doesn't change.

    1 Reply Last reply
    0
    • SGaistS Offline
      SGaistS Offline
      SGaist
      Lifetime Qt Champion
      wrote on last edited by
      #2

      Hi,

      Are you scrolling with the mouse wheel or the arrow keys ? You can check the speed change by using e.g. the page up/page down keys

      Interested in AI ? www.idiap.ch
      Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

      1 Reply Last reply
      0
      • M Offline
        M Offline
        mini.oxford
        wrote on last edited by
        #3

        The speed does not change when I use the mouse wheel and pageup / pagedown

        1 Reply Last reply
        0
        • M Offline
          M Offline
          mini.oxford
          wrote on last edited by
          #4

          I added another scroll outside QListWigdet and i use this method and connect with scroll in qlistwidget, speed scroll changed but when move mouse on qlistwidget speed scroll does not work.

          1 Reply Last reply
          0
          • ssokolowS Offline
            ssokolowS Offline
            ssokolow
            wrote on last edited by ssokolow
            #5

            For anyone who lands here via Google, the problem seems to be that QListWidget overrules whatever value you set via setSingleStep and ScrollPerPixel has no discernible effect.

            This StackOverflow answer with a misleading title demonstrates how to subclass QListView to have the last word.

            The relevant part of the example being as follows:

            class TestListView : public QListView
            [...]
            void TestListView::updateGeometries()
            {
                QListView::updateGeometries();
                verticalScrollBar()->setSingleStep(2);
            }
            

            I can also confirm that it works under PyQt. Here's what I ended up going with to match the scrolling behaviour of GTK+ 2.x icon views:

            class BugFixListView(QListView):
                def updateGeometries(self):
                   """Fix Qt 5.2.1's broken decision to map the OS "1 step = X lines" 
                      scrolling setting without accounting for very tall lines.
            
                      (In my project, "1 step = 3 lines" makes `singleStep` so close
                      to `pageStep` that I don't see a difference.)
            
                      Replace it with the "1 QWheelEvent unit = 1px" relationship that has 
                      served GTK+ 2.x well and appears to be what `QTableView` winds up
                      with thanks to capping icons at roughly the same height as the text.
                    """
            
                    super(BugFixListView, self).updateGeometries()
                    self.verticalScrollBar().setSingleStep(15)
            
            
            1 Reply Last reply
            3
            • G Offline
              G Offline
              gearinvent
              wrote on last edited by
              #6

              I have a QListWidget* in ui->barra_scroll and I feel very smooth with this...

              QScrollBar *qsb = ui->barra_scroll->verticalScrollBar();
              qsb->setSingleStep(5);

              1 Reply Last reply
              0

              • Login

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