Qt World Summit: Submit your Presentation

Problem with scroll in Qlistwidget

  • I have problem with Scroll in QlistWidget. I couldn't change scroll speed. I used:
    This scroll:

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

  • Lifetime Qt Champion


    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

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

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

  • 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()

    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()

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

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

Log in to reply