diff --git a/doric-Qt/example/app/demo/DoricDemoBridge.cpp b/doric-Qt/example/app/demo/DoricDemoBridge.cpp index 16982e28..11f9b33d 100644 --- a/doric-Qt/example/app/demo/DoricDemoBridge.cpp +++ b/doric-Qt/example/app/demo/DoricDemoBridge.cpp @@ -1,6 +1,5 @@ #include #include -#include #include "DoricDemoBridge.h" #include "DoricPanel.h" @@ -38,8 +37,6 @@ DoricDemoBridge::DoricDemoBridge(QQmlApplicationEngine *engine, QObject *parent) } void DoricDemoBridge::navigate(QVariant route) { - qDebug() << mEngine->rootObjects()[0]->children(); - QString name; switch (route.toInt()) { case 0: @@ -117,13 +114,14 @@ void DoricDemoBridge::navigate(QVariant route) { QQmlComponent component(mEngine); const QUrl url(QStringLiteral("qrc:/doric/qml/panel.qml")); component.loadUrl(url); - QQuickItem *quickItem = qobject_cast(component.create()); + QObject *object = component.create(); + QQuickItem *quickItem = qobject_cast(object); DoricPanel *panel = new DoricPanel(mEngine, quickItem); quickItem->setWidth(600); quickItem->setHeight(800); - QQuickItem *root = qobject_cast( - mEngine->rootObjects().at(0)->children().at(1)); - quickItem->setParentItem(root); - panel->config(script, name, NULL); + + QObject *window = mEngine->rootObjects().at(0); + QVariant arg = QVariant::fromValue(object); + QMetaObject::invokeMethod(window, "navigatorPush", Q_ARG(QVariant, arg)); } diff --git a/doric-Qt/example/app/main.qml b/doric-Qt/example/app/main.qml index bf7d978c..47d112e3 100644 --- a/doric-Qt/example/app/main.qml +++ b/doric-Qt/example/app/main.qml @@ -7,10 +7,11 @@ ApplicationWindow { height: 800 title: qsTr("Doric Demo") - Rectangle { + StackView { + id: stack + objectName: "stackView" anchors.fill: parent - - ScrollView { + initialItem: ScrollView { id: entry anchors.fill: parent @@ -88,14 +89,9 @@ ApplicationWindow { } } } - - onChildrenChanged: { - stack.push(this.children[this.children.length - 1]) - } } - StackView { - id: stack - anchors.fill: parent + function navigatorPush(page) { + stack.push(page) } } diff --git a/doric-Qt/example/app/qml.qrc b/doric-Qt/example/app/qml.qrc index 01427393..6137bd70 100644 --- a/doric-Qt/example/app/qml.qrc +++ b/doric-Qt/example/app/qml.qrc @@ -61,6 +61,8 @@ ../doric/resources/util.mjs ../doric/resources/gravity.mjs + + ../doric/resources/doric_icon_back.png diff --git a/doric-Qt/example/doric/resources/doric_icon_back.png b/doric-Qt/example/doric/resources/doric_icon_back.png new file mode 100644 index 00000000..6679febd Binary files /dev/null and b/doric-Qt/example/doric/resources/doric_icon_back.png differ