I have a QListView in Icon mode with lots of icons, so that a scrollbar appears, but the scrolling is not smooth and this IMHO confuses the user since it jumps abruptly from one point to another at each scroll. I would like to make the scrolling smooth but I didn't find anything in the docs. Is it possible?
3 Answers

- 706
- 7
- 11

- 9,134
- 3
- 49
- 80
-
It seems like the correct property but it didn't work. It scrolls just like before. – Massimiliano Torromeo Jan 06 '10 at 21:57
-
I think this is the simplest way to achieve smooth scrolling and it worked for me – warunanc Nov 12 '12 at 03:41
-
This seems like the correct property but I couldn't get it to work as well. Does anyone have any solutions? It seems to playing around with effect `verticalScrollBar()->singlestep()` – Constantin Jul 26 '13 at 23:20
-
1`_my_listview->setVerticalScrollMode(QAbstractItemView::ScrollPerPixel);` worked perfectly fine. Scrolling by dragging the bar itself is now smooth. Using Scrollwheel it still jumps a few items. – KYL3R Feb 06 '19 at 12:01
If I understand your question correctly you would like to redefine the scrolling behavior of the widget. I guess what happens is that listview is getting scrolled by the item's height whenever users hits a scroll arrow (marked as b on the image below).
For a vertical scroll bar connected to a list view, scroll arrows typically move the current position one "line" up or down, and adjust the position of the slider by a small amount. I believe line in this case it is an icon's height. You can adjust items height by installing and item delegate (setItemDelegate) and overriding its sizeHint method. Though this would not help you to solve this problem. What you could try is to create a QListView descendant and override its updateGeometries method. There you can setup the vertical scrollbar step to the value you want, I guess 1 or 2 for this task. Below is an example of the custom listview:
class TestListView : public QListView
{
Q_OBJECT
public:
explicit TestListView(QWidget *parent = 0);
protected:
virtual void updateGeometries();
};
TestListView::TestListView(QWidget *parent) :
QListView(parent)
{
//???
}
void TestListView::updateGeometries()
{
QListView::updateGeometries();
verticalScrollBar()->setSingleStep(2);
}
hope this helps, regards

- 4,933
- 8
- 63
- 86

- 20,186
- 2
- 61
- 64
-
-
Setting singleStep and pageStep in updateGeometries seems to work properly for mouse scroll. – Adrian Maire Jan 01 '23 at 14:03
I have a QlistWidget* in ui->barra_scroll and I feel very smooth with this.
QScrollBar *qsb = ui->barra_scroll->verticalScrollBar();
qsb->setSingleStep(5);

- 235,170
- 19
- 170
- 241