Hi,
In a QTreeView I would like to show a DecorationRole icon depending on the expanded value, e.g. open folder icon for expanded, closed folder for not expanded.
Thanks!
Thomas
Hi,
In a QTreeView I would like to show a DecorationRole icon depending on the expanded value, e.g. open folder icon for expanded, closed folder for not expanded.
Thanks!
Thomas
You could use the QTreeView's signal expanded(const QModelIndex & index), and connect it to a slot of some object which can access the model->setData(OpenIcon, Qt::DecorationRole), and similarly use the QTreeView's signal collapsed(const QModelIndex & index), and connect it to a slot of some object which can access the model->setData(CloseIcon, Qt::DecorationRole).
Note that, when you have multiple views connected to same model, expanding the item in a view will not expand the items in other view, but their icon will change, and will appear that the icon and actual state (expanded/collapsed) do not match.
When you know how to do it then you may do it wrong.
When you don't know how to do it then it is not that you may do it wrong but you may not do it right.
Thank you.
Does it make sense to make a feature request for such things? If yes, how to make this?
Bookmarks