Problem with scroll in Qlistwidget
-
wrote on 8 Sept 2014, 07:15 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.
-
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
-
wrote on 8 Sept 2014, 07:37 last edited by
The speed does not change when I use the mouse wheel and pageup / pagedown
-
wrote on 8 Sept 2014, 07:48 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.
-
wrote on 18 Sept 2016, 00:16 last edited by ssokolow
For anyone who lands here via Google, the problem seems to be that
QListWidget
overrules whatever value you set viasetSingleStep
andScrollPerPixel
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)
-
wrote on 12 May 2020, 17:46 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);