Adding a property to QTreeWidgetItem
-
Is is possible to add a property, I know that's not possible, but something similar at least to it to a QTreeWidgetItem. I want to be able to add a setting for each row, so I know how to display it.
So I have thisQTreeWidget
which has a bunch of stuff in it and I want to make it display a column in either hex, decimal or octal depending on the choice from aQActionGroup
when you right click it. My current solution would be to add a suffix to it but it would be nicer to have a property or something. -
@vikke
You add whatever "properties" you want by sub-classingQTreeWidgetItem
and putting whatever member variables you want into that. Then you add created instances of your sub-class into theQTreeWidget
. This principle applies in many places in Qt. -
Hi
Just as a note.
There is also UserRoles for such data.
QTreeWidgetItem * item = new QTreeWidgetItem();
item->setData(0,Qt::UserRole, true );
item->setData(0,Qt::UserRole+1, 100 );