Qt widgets: setRange for verticalScrollbar of QListView
-
Hello, I have my sub classing QListView.
I made my own paintEvent() of list view and I would like to setRange() for my vertical scrollbar of list view. But it seems that the range is calculated by QListView and I can't change it. Is there any solution that I can't modify the scroll bar of list view. -
Hi,
It's pretty unusual to modify the paint event of such a widget, generally a QStyledItemDelegate is used for special rendering. Why did you do it ?
-
Yes, it's unusual. I'm doing some transformation which modify the height of the view. I tried to paint with delegate, but it seems that I need some kind of global position in the view to make sure my calculate is right. So I redefined the paintEvent of QListView.
Back to the question, I found that setRange is called in updateVertical/HorizontalScrollBar inside of updateGeometries(). So do setSingleStep and setPageStep. So I redifined updateGeometries() to make the range is not reset. Works fine. I don't know if there will be some side effect.
Ty for your advice.
[quote author="SGaist" date="1404941104"]Hi,It's pretty unusual to modify the paint event of such a widget, generally a QStyledItemDelegate is used for special rendering. Why did you do it ?[/quote]
-
The best is to test it extensively ;)