dimanche 6 décembre 2015

Add an extra column in a vertical QScrollBar

I have a QTreeView (or a QTreeWidget) with almost 500 rows. The widget does display a Vertical ScrollBar on the right but I want to customize it a bit for my use.

I want to add an extra column to the right of the scroll bar which can display a few icons to indicate the position of some of the rows.

A rough sketch of what I plan to implement can be seen in the image here: http://ift.tt/1YTkkAJ The colourful shapes would be icons to the specific rows. I cannot draw those icons on the scrollbar itself because it doesn't look clean enough.

I tried extending QScrollBar and overriding the paintEvent in it to draw the icons and change the geometry of the scroll bar. However, I can't get it to work.

Using a horizontal layout with QScrollBar and another widget to draw the icons is a possible solution for it, but I am looking for a solution in which it could be done by simply inheriting the QScrollBar so that I wouldn't have issues in integrating it with other Views.

Has anyone ever tried it or do you have any idea on how to do it?

Aucun commentaire:

Enregistrer un commentaire