change qml component to quick item

This commit is contained in:
王劲鹏 2021-02-19 10:04:54 +08:00 committed by osborn
parent 3eeb062d2e
commit 36427898cb
9 changed files with 29 additions and 24 deletions

View File

@ -10,6 +10,6 @@ void DoricPanel::config(QString script, QString alias, QString extra) {
void DoricPanel::config(DoricContext *context) {
this->mContext = context;
this->mContext->getRootNode()->setRootView();
this->mContext->build(960, 720);
this->mContext->getRootNode()->setRootView(this);
this->mContext->build(width(), height());
}

View File

@ -1,9 +1,11 @@
#ifndef PANEL_H
#define PANEL_H
#include <QQuickItem>
#include "DoricContext.h"
class DoricPanel {
class DoricPanel : public QQuickItem {
private:
DoricContext *mContext;
int renderedWidth = -1;

View File

@ -1,5 +1,4 @@
#include <QDebug>
#include <QQuickItem>
#include <QQuickView>
#include "DoricDemoBridge.h"
@ -15,15 +14,16 @@ void DoricDemoBridge::navigate(QVariant route) {
QString script = DoricUtils::readAssetFile("/doric/bundles", name);
QQuickView *view = new QQuickView();
view->setWidth(960);
view->setHeight(720);
QColor color("blue");
view->setColor(color);
view->setWidth(450);
view->setHeight(800);
QColor blue("blue");
view->setColor(blue);
view->show();
view->rootObject();
DoricPanel *panel = new DoricPanel();
panel->setParent(view);
panel->setWidth(450);
panel->setHeight(800);
panel->config(script, name, NULL);
break;
}

View File

@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE QtCreatorProject>
<!-- Written by QtCreator 4.11.1, 2021-02-05T15:58:19. -->
<!-- Written by QtCreator 4.11.1, 2021-02-10T15:05:52. -->
<qtcreator>
<data>
<variable>EnvironmentId</variable>

View File

@ -1,3 +1,5 @@
#include "DoricRootNode.h"
void DoricRootNode::setRootView() {}
void DoricRootNode::setRootView(QQuickItem *rootView) {
this->mView = rootView;
}

View File

@ -1,13 +1,15 @@
#ifndef ROOTNODE_H
#define ROOTNODE_H
#include <QQuickItem>
#include "DoricStackNode.h"
class DoricRootNode : public DoricStackNode {
public:
using DoricStackNode::DoricStackNode;
void setRootView();
void setRootView(QQuickItem *rootView);
};
#endif // ROOTNODE_H

View File

@ -1,14 +1,13 @@
#include "DoricStackNode.h"
QQmlComponent *DoricStackNode::build() {
QQmlComponent *component = new QQmlComponent();
QQuickItem *DoricStackNode::build() {
QQmlComponent component;
const QUrl url(QStringLiteral("qrc:/stack.qml"));
component->loadUrl(url);
component.loadUrl(url);
return component;
QQuickItem *item = qobject_cast<QQuickItem *>(component.create());
return item;
}
void DoricStackNode::blendLayoutConfig() {
DoricViewNode::blendLayoutConfig();
}
void DoricStackNode::blendLayoutConfig() { DoricViewNode::blendLayoutConfig(); }

View File

@ -8,7 +8,7 @@ class DoricStackNode : public DoricGroupNode
public:
using DoricGroupNode::DoricGroupNode;
QQmlComponent *build() override;
QQuickItem *build() override;
void blendLayoutConfig() override;
};

View File

@ -1,16 +1,16 @@
#ifndef DORICVIEWNODE_H
#define DORICVIEWNODE_H
#include <QQmlComponent>
#include <QQuickItem>
#include "../utils/DoricContextHolder.h"
class DoricViewNode : public DoricContextHolder {
protected:
QQmlComponent mView;
QQuickItem *mView;
virtual QQmlComponent *build() = 0;
virtual QQuickItem *build() = 0;
virtual void blendLayoutConfig();