Qt World Summit: Register Today!

Transparent scroll bar in QListView

  • I'd like to make a background of a scrollbar of QListView transparent. It should be painted over the content. Something like "this":http://i.imgur.com/P3aIh.png. I searched for where is the scrollbar drawn but find nothing. :) Please, point me to methods I need to reimplement. Or may be it can be done by qss?

  • As far as I can see, the position of the scroll bar is set in the private class QAbstractScrollAreaPrivate::layoutChildren(). So this is the method I need to reimplement, but is it ok to derive from privite class? Are there any workarounds?

  • Why not use a QML-based list instead then? In QML, this is very easy while in the QWidget world, this is quite a hassle. You can keep the rest of your application using classic widgets, but just replace your QListView with a QDeclarativeView, load a QML file that defines the list and the delegates for the items, and set your model as the model for the list. I think that makes it far easier to reach your goal of creating a list like you show on the screenshot.

  • I ended up with this hack. I just created a new vertical scroll bar, placed it onto viewport and connected it with the original scroll bar. Then I just hidden the original scrollbar :)

    !http://i.imgur.com/N6e62.png(scrollbar over the view)!

Log in to reply