From dba0569256f5ca107cab1528ae0a5c516e7c9ec2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=8E=8B=E5=8A=B2=E9=B9=8F?= Date: Wed, 9 Jun 2021 10:09:24 +0800 Subject: [PATCH] add nav back icon & complete c++ invoke qml nav push --- doric-Qt/example/app/demo/DoricDemoBridge.cpp | 14 ++++++-------- doric-Qt/example/app/main.qml | 16 ++++++---------- doric-Qt/example/app/qml.qrc | 2 ++ .../example/doric/resources/doric_icon_back.png | Bin 0 -> 1098 bytes 4 files changed, 14 insertions(+), 18 deletions(-) create mode 100644 doric-Qt/example/doric/resources/doric_icon_back.png 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 0000000000000000000000000000000000000000..6679febdbe96c991775bbcc24409019685024c18 GIT binary patch literal 1098 zcmV-Q1hxB#P)Px(1W80eRA>e5SNa^nKxz<0b0-x-SOi!R6g^=HC0h z@0|1QJ?D+jSG}qhs7wnqH8u4&Ha5<&MWfMPyDa>6Cpwu2&?n2~@*S)Z;5vT4e{N}M zDPd>L-wW88Xm<|4p9lE6m@l7g+mLb*yO>PRL)Z)f{54FFfQx}Z;Ed@-l!0;~(A?|;m9a&sld@l7?`ys0ntc*{k zQbAb$9_E}-=6!{H2;ko+dds3V4|H^NY?+;%eE<&(D5$cbP^f2NVPQ(q+Y+@9h{xl# zD=RAx0e;i|j*$6`b^w-tZwu`oCb>?axw$z~EEf4vb}7$G*VNP`=jZ1?DSAhutJ`QI zk%+FXt&IUumqZ1t&!Ba>4W7?%%>ykhE!$RCSD#_cb_pK+X;{7o;J+w(S43AlfNe5f zC=^}+(I)V)`b2$w{eE5GX#vL`faQ0>^4!Z?xuCdSVz=qTZu4E}T<<#a04%>7mVXUY ztr8h5KibgH(5o9fpJ|%_cAGueCdbjXE8s`k+S-n$)9Jj_>+0Jg0L$;iR`~*;ViFiE zKb%Y^k4;Wa7NlNh-|{z zBQyEHpviH*a5(%C9!O!lL7Lt>2z@b^%keDuFPCWoNRMYCk;q$+=m*k`LI`pW)9-+R>@VBsZM+Yj??gs882J8qU$0?%Fpy=Tyaqw;KFdg{)ZMr20Rs?I37p1E zpViZtsl;)wPGj2yNCXz&g?C^KP0fc!>+0$TGMP-yAgt@|hyX!VbUIA}EE92{b)wBs z7FQR`OO}~J=X%$%2Mk0NT~d++%SM)u@Wg~cYW?2Ma+77JqIX4f%>xFSivFxZ5-cNG zPQnwT2C4OXE6Y!op^Dy-X!#&B^E8%|EGt1`M2_cni#ER1~l{Kd;|_e$$^AAm+;Fb!{FnhyZAr0l_?nVwpiZ Qe*gdg07*qoM6N<$f?O;2W&i*H literal 0 HcmV?d00001