View Full Version : Accessing QML array from c++

4th September 2012, 15:29
I have created an array in javascript in QML and filled it using javascript. This array contains QML objects.
I need to access and update this array using c++ in my main QT function.
I have searched alot but most of results talk about solution for accessing cpp objects defined in QML.
What I need is vice versa.
Would you please help?

4th September 2012, 15:34
You need to locate a child object (http://qt-project.org/doc/qt-4.8/qtbinding.html#locating-child-objects) and then you will be able to modify a list.

4th September 2012, 15:39
Thanks for your reply Spirit.
But what I am looking for, is to access a java script array in QT main function using c++.
I have defined following arrays in my QML.js
.pragma library
var dObjects1 = [];
var dObjects2 = [];

I need to access dObjects1 and dObjects2 in the main QT function.

4th September 2012, 15:40
It's not possibly. You should attach these object to QML objects properties.