---------- Mainitem.qml
Qt Code:
Switch view
import QtQuick 1.0
Item1 {
width: 100; height: 100
property string mrprefcolor: itemB.mypreferredcolor // Binding
ItemA1 {
id: square
Rectangle {
color: "red"
width: 10
height: 10
}
}
itemB {}
}
import QtQuick 1.0
Item1 {
width: 100; height: 100
property string mrprefcolor: itemB.mypreferredcolor // Binding
ItemA1 {
id: square
Rectangle {
color: "red"
width: 10
height: 10
}
}
itemB {}
}
To copy to clipboard, switch view to plain text mode
To copy to clipboard, switch view to plain text mode
---------- itemB.qml -------------
Qt Code:
Switch view
import QtQuick 1.0
property string mypreferredcolor: "red"
Item2 {
property length: 6
ItemB1 {
id: idc
Rectangle {
color: "red"
width: 10
height: 10
property rectype: 0
}
}
}
import QtQuick 1.0
property string mypreferredcolor: "red"
Item2 {
property length: 6
ItemB1 {
id: idc
Rectangle {
color: "red"
width: 10
height: 10
property rectype: 0
}
}
}
To copy to clipboard, switch view to plain text mode
Hello
I'm trying to read the Mainitem.qml mypref property from C++, but it does not work. Is it because the property is binded?
I have tried the following (obj being the current *QObject):
metaObject->property(i).read(obj).toString(); // i is the index of mrprefcolor
and
= obj->property("mrprefcolor").toString();
Any thoughts
Thanks;
Mut.
Bookmarks