QVariantMap as model for Repeater
Solved
QML and Qt Quick
-
Is there a way of using exposed from C++ QVariantMap as a model for repeater?
Code below doesn't work:
ColumnLayout { Layout.fillWidth: true Layout.fillHeight: true Repeater { model: modelsQVariantMap Text { horizontalAlignment: Text.AlignRight anchors.right: parent.right text: { console.log("lol") return "text" } color: "white" } } }
It isn't even printing anything to console
-
@Kyeiv
https://doc.qt.io/qt-5/qtquick-modelviewsdata-modelview.html#modelsthose are your possibilities
-
@Kyeiv
the type should rather be of QVariantList if you intend to use it as a model -
@raven-worx so the only way is to convert QVariantMap to QVariantList?
-
@Kyeiv said in QVariantMap as model for Repeater:
so the only way is to convert QVariantMap to QVariantList?
Or to create a model based on
QAbstractItemModel
(cf. How to Use a Custom Class in C++ Model and QML View) -
@Kyeiv
https://doc.qt.io/qt-5/qtquick-modelviewsdata-modelview.html#modelsthose are your possibilities