Can I Customize QTreeView this way?



  • I've built a model for QTreeView, now it's time to customize QTreeView, to display items in a "fancy" way.
    For example, I'd like each tree item looks like this:

    !http://i.6.cn/cvbnm/e0/d8/8d/3e562af00fd58ba8a7da96cd6a58cabc.png(mockup)!

    Basically, I want a icon on the left, some texts of different font sizes, a progress bar...
    When double clicked the parent item(i.e. expanding treeview), child items will be displayed in similar way.

    I don't know how to render items in the way I wanted, what's worse, I'm not sure where to get started.
    I've tried a very simple QItemDelegate from the Qt SDK examples, but it is not enough.

    Any suggestion, reference link will be appreciated, thanks.



  • Yes, a delegate is definitely what you want. Subclass QStyledItemDelegate and do your custom painting there.


Log in to reply
 

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