add nav back icon & complete c++ invoke qml nav push
This commit is contained in:
parent
7fe12e769e
commit
dba0569256
@ -1,6 +1,5 @@
|
|||||||
#include <QDebug>
|
#include <QDebug>
|
||||||
#include <QQmlContext>
|
#include <QQmlContext>
|
||||||
#include <QQuickView>
|
|
||||||
|
|
||||||
#include "DoricDemoBridge.h"
|
#include "DoricDemoBridge.h"
|
||||||
#include "DoricPanel.h"
|
#include "DoricPanel.h"
|
||||||
@ -38,8 +37,6 @@ DoricDemoBridge::DoricDemoBridge(QQmlApplicationEngine *engine, QObject *parent)
|
|||||||
}
|
}
|
||||||
|
|
||||||
void DoricDemoBridge::navigate(QVariant route) {
|
void DoricDemoBridge::navigate(QVariant route) {
|
||||||
qDebug() << mEngine->rootObjects()[0]->children();
|
|
||||||
|
|
||||||
QString name;
|
QString name;
|
||||||
switch (route.toInt()) {
|
switch (route.toInt()) {
|
||||||
case 0:
|
case 0:
|
||||||
@ -117,13 +114,14 @@ void DoricDemoBridge::navigate(QVariant route) {
|
|||||||
QQmlComponent component(mEngine);
|
QQmlComponent component(mEngine);
|
||||||
const QUrl url(QStringLiteral("qrc:/doric/qml/panel.qml"));
|
const QUrl url(QStringLiteral("qrc:/doric/qml/panel.qml"));
|
||||||
component.loadUrl(url);
|
component.loadUrl(url);
|
||||||
QQuickItem *quickItem = qobject_cast<QQuickItem *>(component.create());
|
QObject *object = component.create();
|
||||||
|
QQuickItem *quickItem = qobject_cast<QQuickItem *>(object);
|
||||||
DoricPanel *panel = new DoricPanel(mEngine, quickItem);
|
DoricPanel *panel = new DoricPanel(mEngine, quickItem);
|
||||||
quickItem->setWidth(600);
|
quickItem->setWidth(600);
|
||||||
quickItem->setHeight(800);
|
quickItem->setHeight(800);
|
||||||
QQuickItem *root = qobject_cast<QQuickItem *>(
|
|
||||||
mEngine->rootObjects().at(0)->children().at(1));
|
|
||||||
quickItem->setParentItem(root);
|
|
||||||
|
|
||||||
panel->config(script, name, NULL);
|
panel->config(script, name, NULL);
|
||||||
|
|
||||||
|
QObject *window = mEngine->rootObjects().at(0);
|
||||||
|
QVariant arg = QVariant::fromValue(object);
|
||||||
|
QMetaObject::invokeMethod(window, "navigatorPush", Q_ARG(QVariant, arg));
|
||||||
}
|
}
|
||||||
|
@ -7,10 +7,11 @@ ApplicationWindow {
|
|||||||
height: 800
|
height: 800
|
||||||
title: qsTr("Doric Demo")
|
title: qsTr("Doric Demo")
|
||||||
|
|
||||||
Rectangle {
|
StackView {
|
||||||
|
id: stack
|
||||||
|
objectName: "stackView"
|
||||||
anchors.fill: parent
|
anchors.fill: parent
|
||||||
|
initialItem: ScrollView {
|
||||||
ScrollView {
|
|
||||||
id: entry
|
id: entry
|
||||||
|
|
||||||
anchors.fill: parent
|
anchors.fill: parent
|
||||||
@ -88,14 +89,9 @@ ApplicationWindow {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
onChildrenChanged: {
|
|
||||||
stack.push(this.children[this.children.length - 1])
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
StackView {
|
function navigatorPush(page) {
|
||||||
id: stack
|
stack.push(page)
|
||||||
anchors.fill: parent
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -61,6 +61,8 @@
|
|||||||
|
|
||||||
<file alias="util.mjs">../doric/resources/util.mjs</file>
|
<file alias="util.mjs">../doric/resources/util.mjs</file>
|
||||||
<file alias="gravity.mjs">../doric/resources/gravity.mjs</file>
|
<file alias="gravity.mjs">../doric/resources/gravity.mjs</file>
|
||||||
|
|
||||||
|
<file alias="doric_icon_back.png">../doric/resources/doric_icon_back.png</file>
|
||||||
</qresource>
|
</qresource>
|
||||||
|
|
||||||
<qresource prefix="/resource/main/">
|
<qresource prefix="/resource/main/">
|
||||||
|
BIN
doric-Qt/example/doric/resources/doric_icon_back.png
Normal file
BIN
doric-Qt/example/doric/resources/doric_icon_back.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 1.1 KiB |
Reference in New Issue
Block a user