Qt Forum

    • Login
    • Search
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Unsolved

    Update: Forum Guidelines & Code of Conduct


    Qt World Summit: Early-Bird Tickets

    Problem with scroll in Qlistwidget

    General and Desktop
    4
    6
    3366
    Loading More Posts
    • 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
      mini.oxford last edited by

      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 Reply Quote 0
      • SGaist
        SGaist Lifetime Qt Champion last edited by

        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 Reply Quote 0
        • M
          mini.oxford last edited by

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

          1 Reply Last reply Reply Quote 0
          • M
            mini.oxford last edited by

            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 Reply Quote 0
            • ssokolow
              ssokolow last edited by ssokolow

              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 Reply Quote 3
              • G
                gearinvent last edited by

                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 Reply Quote 0
                • First post
                  Last post