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

how to create array of similar graphical objects in qml?

$
0
0
Hi pnmrvvtl, In QML you can create a property with type of list. Code must look like: property list<Rectangle> listItem: [Rectangle {}, Rectangle {}] In you C++ module you can get access to it using code like this:     QApplication app(argc, argv);       QQmlApplicationEngine engine;     engine.load(QUrl(QStringLiteral("qrc:/main.qml")));       QObject* item = engine.rootObjects().first();     if(item)     {         QQmlListProperty<QObject> list = qvariant_cast<QQmlListProperty<QObject> >(item->property("listItems"));         int i = 0, count = list.count(&list);         while(i < count)         {             QQuickItem* obj = qobject_cast<QQuickItem*>(list.at(&list, i));             qDebug()<<"obj: "<<obj;               ++i;         }     }       return app.exec(); QML basic type documentation [qt-project.org].

Viewing all articles
Browse latest Browse all 4972

Trending Articles