[Interest] QTreeView c.s.: showing horizontal scrollbar without wheel/touch-based horizontal scrolling

René J.V. Bertin rjvbertin at gmail.com
Tue Jul 11 00:16:30 CEST 2017


Hi,

I'd like to ask some feedback on something I've been tinkering with.

I recently made a proposition for a project manager widget to use a horizontal scrollbar instead of text eliding (with popup expansion in tooltips), like Qt Creator does. The main devs of the application in question didn't like the idea of being able to scroll the treeview via touch input (e.g. 2-finger scrolling) as this is often too sensitive and it thus becomes hard to scroll the view purely vertically.

So I added an event filter that removes the horizontal component from incoming QWheelEvents (unless the come from a scroll wheel, which we can know on Mac). The result is a treeview widget that you can position horizontall w.r.t. the viewport with the scrollbar and in which you can scroll vertically without using the scrollbar.
They didn't like that either: too complex and "hacky" (and "should be implemented in the upstream widget").

I developed the filter with this little demonstrator: https://github.com/RJVB/wheelscrollfilter ; in the target application I had to use the approach with an eventFilter installed on the QTreeView's viewport.

Question: am I doing this the most efficient/elegant way possible? Maybe Qt already provides a switch to disable scrolling via gestures or scroll wheels?

Thanks,
René




More information about the Interest mailing list