View Full Version : QTreeview DecorationRole icon depending on expanded
ctgrund
9th April 2013, 19:56
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
Santosh Reddy
10th April 2013, 09:46
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.
ctgrund
12th April 2013, 08:59
Thank you.
Does it make sense to make a feature request for such things? If yes, how to make this?
Powered by vBulletin® Version 4.2.5 Copyright © 2024 vBulletin Solutions Inc. All rights reserved.