Hi Bo

I tried the same from pure QML, everything works fine :/
http://pastebin.com/DHYai3RB

Not that big help for your case, but at least you know that QML part is fine.

BR,
Artem.

On Aug 24, 2011, at 11:20 AM, Bo Thorsen wrote:

> 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

_______________________________________________
Qt-qml mailing list
[email protected]
http://lists.qt.nokia.com/mailman/listinfo/qt-qml

Reply via email to