Solution is to use a QMap containing the different values for text and icon.
in the datatype:
const QMap<QString,QVariant>& toMap()
{
QMap result;
result.insert("text", m_text);
....
return result;
}
In the model:
QVariant MyDataModel::data(const QModelIndex& index, int role) const
{
...
CellData myData; // Value for the current table cell
return QVariant(myData.toMap());
}
in the qml
itemDelegate:
Item {
...
Text {
...
text: styleData.value["text"]
...
}
Image {
...
source: styleData.value["image"]
...
}
}
↧