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:


    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.