How to create attribute for QStrandardItem?
-
You can define your own "Qt::ItemDataRoles":/doc/qt-4.8/qt.html#ItemDataRole-enum and use data() and setData() methods of the items.
For example:
@
enum MyItemDataRoles { MyIdRole = Qt::UserRole + 1, MyStringDataRole };QStandardItem *item = ...;
item->setData(23, MyIdRole);
int id = item->data(MyIdRole).toInt();item->setData("blubb", MyStringDataRole);
qDebug() << item->data(MyStringDataRole).toString();
@