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

Access dynamic created ListModel elements from C++!

$
0
0
Hi Andre, Yes, it depends :) And I find another way to play with ListView model 1. qmlRegisterType a customized C++ Model such as: qmlRegisterType<MyModel>("cn.com.i-soft.demo", 1, 0, "MyModel"); 2. QStringList property or QObjectList, QList such as: Q_PROPERTY(QStringList myLists READ myLists NOTIFY myListsChanged) 3. put MyModel in QML such as: import cn.com.i-soft.demo 1.0 ... ListView {                                                                             ...                                               MyModel {                                                                       id: myModel                                                                   }                                                                                                                                                       model: myModel.myLists                                                   delegate: Rectangle {                                                                   ...                                               Text { text: modelData }                                                       }                                                                               } Regards, Leslie Zhai

Viewing all articles
Browse latest Browse all 4972

Trending Articles