PDA

View Full Version : Acessing individual properties of nested QML object from C++



mut
25th March 2016, 06:00
---------- Mainitem.qml


import QtQuick 1.0

Item1 {
width: 100; height: 100

ItemA1 {
id: square

Rectangle {
color: "red"
width: 10
height: 10
}
}

itemB {}
}

---------- itemB.qml -------------


import QtQuick 1.0

Item2 {
property length: 6

ItemB1 {
id: idc

Rectangle {
color: "red"
width: 10
height: 10
property rectype: 0
}
}

}

Hello;

How to read the properties of ItemB1 Rectangle (e.g rectype) from my C++ code (we know only the path to Mainitem.qml)?

Thanks;

Mut

anda_skoa
25th March 2016, 10:17
Standard question: why do you want do invert the dependency direction and make C++ depend on specific QML?

Cheers,
_

mut
25th March 2016, 15:44
Thanks for the reply.
I want to keep my .qml files but I want to access its data (the properties of the qml) from my C++ class?
Thanks
Mut

anda_skoa
26th March 2016, 11:31
Sorry, misunderstanding, I'll try to rephrase.

Making the C++ part of an application dependent on certain QML code is usually a bad idea, as it puts restrictions on the QML side that are often unnecessary.

What do you want to do that you think requires to access QML objects from C++?

Cheers,
_