Quantcast
Channel: Qt DevNet forums: Qt Quick 1283365070**
Viewing all articles
Browse latest Browse all 4972

[Solved] Display text and image in Tableview

$
0
0
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"]         ...     } }

Viewing all articles
Browse latest Browse all 4972

Trending Articles