Hi all,
I am trying to create a stackedwidget like item with this QML code:
Item {
id: window
anchors.fill: parent
Item {
id: windowRect
objectName: "windowRect"
anchors.fill: parent
property string current: ""
onCurrentChanged: setOpacities();
function setOpacities() {
console.log("w_length: " + stack.children.length);
}
Item {
id: stack
objectName: "stack"
width: window.width
anchors.fill: parent
function printChildren() {
console.log("s_length: " + children.length)
}
}
}
}
I modify the stack from C++ like this:
QDeclarativeItem* stack =
view->rootObject()->findChild<QDeclarativeItem*>("stack");
Q_ASSERT(stack);
page->setParentItem(stack);
QMetaObject::invokeMethod(stack, "printChildren");
QDeclarativeItem* window =
view->rootObject()->findChild<QDeclarativeItem*>("windowRect");
Q_ASSERT(window);
window->setProperty("current", page->objectName());
QMetaObject::invokeMethod(stack, "printChildren");
It prints this:
s_length: 1
w_length: 0
s_length: 1
What is going on here? How can the length of the list of children of the
stack be 0 when accessing it from the windowRect function?
Bo Thorsen,
Fionia Software.
--
Expert Qt and C++ developer for hire
Contact me if you need expert Qt help
http://www.fioniasoftware.dk
_______________________________________________
Qt-qml mailing list
[email protected]
http://lists.qt.nokia.com/mailman/listinfo/qt-qml