Does ScrollPerPixel ever work?
So I have a QTreeWidget derived class that has big item height (200 pixels, for example). And I often have about 100 items in the view. I found even if I set the vertical scroll mode to ScrollPerPixel, it still scrolls too fast (or too "jumpy"). If I understand correctly, shouldn't ScrollPerPixel mean scroll pixel by pixel? I would expect the view scrolls smoothly like a static image. If I clicked on the up/down arrow buttons on the scroll bar, I expect the view to scroll up/down by one pixel. Instead, it scrolls about 180 pixels a time. How is the step size determined? Is there any way to set it to 1? I tried to obtain the vertical scrollbar and set the step size to 1, but it didn't work.
No, I think you misunderstand what ScrollPerPixel means. It means that scrolling is not snapped to scroll only complete items at a time, but that you can scroll freely, meaning that only a single line of pixels might be drawn of the last or the first item.
You can adapt the step size if you want.
Thanks for the reply. How do I set step size? I tried to put
in the constructor or in the code where I add items to the view. Neither worked.
yes that should work .. I just tried something like this and it just works fine.
verticalScrollBar = new QScrollBar(centralWidget);
or can u paste some test code here that exactly shows the problem
You might have to do that after a layout change, and both the constructor and the item adding is too early for that. You can test that by simply setting it with a timer a second after setting the data or something like that.
Best solution would be to dig through the sources of QTreeView and see where/when the step size is set, so you can re-set it afterwards, of course.
I tried set step size in a single shot timer slot. It worked out great. Thanks for the tip.
I wish ItemView could have a explicit function to overwrite the auto step size resetting at every layout refresh.
With that working, you might want to see if you can find a method that you can use for this. The timer was just a trick to see if the idea worked at all :-)
I know, it's not perfect. It might fail if the layout took too long to refresh. But it's not critical so I can live with it. I just don't feel like diving into the Qt source code now:-|