[SOLVED] QTreeView hierarchy decorations

  • I would like make QTreeView to look like QTreeWidget. One of the decorations in QTreeWidget are these lines: http://i.imgur.com/wzOuIj0.png
    Do I really have to draw them manually in my own item delegate?

  • Moderators

    By default branch indicators depend on a used style. For example on windows the style "Windows" shows them while "Fusion" or "WindowsVista" doesn't. And it's the case for both QTreeView and QTreeWidget.

    If you want to have them drawn regardless of the used style (which is a little evil if you ask me) then yes, you need to draw them yourself to make them look however you want. Preferably you can do that by subclassing QTreeView and implementing drawBranches() and not via a delegate, as it is intended to draw items and branches are not considered part of them.

    You can also style the branches using stylesheets. Here's an example of how to do that.

Log in to reply

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.