add quick item to quick view dynamically
This commit is contained in:
@@ -14,17 +14,32 @@ void DoricDemoBridge::navigate(QVariant route) {
|
||||
QString script = DoricUtils::readAssetFile("/doric/bundles", name);
|
||||
|
||||
QQuickView *view = new QQuickView();
|
||||
view->setWidth(450);
|
||||
view->setHeight(800);
|
||||
QColor blue("blue");
|
||||
view->setColor(blue);
|
||||
view->show();
|
||||
{
|
||||
const QUrl url(QStringLiteral("qrc:/doric/qml/view.qml"));
|
||||
view->setSource(url);
|
||||
view->setWidth(450);
|
||||
view->setHeight(800);
|
||||
}
|
||||
|
||||
DoricPanel *panel = new DoricPanel();
|
||||
panel->setParent(view);
|
||||
panel->setParentItem(view->rootObject());
|
||||
panel->setWidth(450);
|
||||
panel->setHeight(800);
|
||||
panel->config(script, name, NULL);
|
||||
|
||||
QQmlEngine *engine = view->engine();
|
||||
QQmlComponent component(engine);
|
||||
const QUrl empty(QStringLiteral("qrc:/doric/qml/panel.qml"));
|
||||
component.loadUrl(empty);
|
||||
QQuickItem *childItem = qobject_cast<QQuickItem *>(component.create());
|
||||
|
||||
if (childItem == nullptr) {
|
||||
qCritical() << component.errorString();
|
||||
return;
|
||||
}
|
||||
childItem->setParentItem(view->rootObject());
|
||||
|
||||
view->show();
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user