Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct
[SOLVED]access the property of elements of all components created ever in one ducument
-
an important question for me
i have a document and i want create some QML elements in that by this code
@
var component5 = Qt.createComponent("Shape_circle.qml");
if (component5.status == Component.Ready) {
var circle = component5.createObject(adder);
circle.x=mouseX
circle.y=mouseY
component5.destroy();
}
@
that is called using createComponent metod for having same elements in a doc...
now! what i want is that how can i have this elements in a list
for example, i create 10 shapes and i want to change second shape color or size...
or i want to save this shapes size and colors in a file...
can U help me?
thanks
-
Hi,
if I understood you correctly, you can store the objects in an array
@
property var arrayOfObjects : []
var circle = component5.createObject(adder);
arrayOfObjects[0] = circle
@
-
thanks...but it contains an error: Expected token `,'
and red underline under var in line1
-
OfCourse, if you use as it is. property var arrayOfObjects is meant to be global.
-
thank u veryyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyy much!!!!!
it work!
-
an other question...
can i access childrens of an element
for example in circle.qml file i have a button that i want change its color in especial created element...
-
Yes. From QML you can use the children property. For eg
@
circle.children[0].color = "red" //just find the exact element
@
-
thanks again!!!!!!!
it work too!!!
-
thanks again!!!!!!!
it work too!!!