I have to build a QML UI dynamically. I'd like to use a PageStack, but I
can't seem to find the object.
I have this simple main.qml that's set on a view:
Window {
id: window
PageStack {
id: pageStack
anchors.fill: parent
}
}
If I change the PageStack declaration to be a Text (id textItem)
instead, I can find the Text object with this code:
QDeclarativeItem* textItem =
QMLView::getInstance()->rootObject()->findChild<QDeclarativeItem*>("textItem");
When I run QMLView::getInstance()->rootObject()->dumpObjectTree() I get
this:
Window_QMLTYPE_14::
QDeclarativeRectangle::
QDeclarativeBind::
QDeclarativeBind::
QDeclarativeConnections::
QDeclarativeAbstractBoundSignal::
QDeclarativeAbstractBoundSignal::
PageStack_QMLTYPE_18::
QObject_QML_19::
QDeclarativeComponent::
QDeclarativeAbstractBoundSignal::
But trying to run findChild on pageStack returns 0 no matter what type
I'm trying.
Any ideas how I can access the pageStack?
My backup plan at this point is to implement a javascript function to
instantiate a page and add that to the pagestack. But it seems odd that
I can't do it with C++ code.
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