From 9f1839f2f74fec15041a63dbabefe0816f8ca585 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=8E=8B=E5=8A=B2=E9=B9=8F?= Date: Tue, 1 Jun 2021 16:15:05 +0800 Subject: [PATCH] change append child method --- doric-Qt/example/doric/resources/slider.qml | 5 +++++ doric-Qt/example/doric/shader/slider/DoricSliderNode.cpp | 6 +++++- 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/doric-Qt/example/doric/resources/slider.qml b/doric-Qt/example/doric/resources/slider.qml index e6a0a4fb..17bf3616 100644 --- a/doric-Qt/example/doric/resources/slider.qml +++ b/doric-Qt/example/doric/resources/slider.qml @@ -40,4 +40,9 @@ SwipeView { onBorderColorChanged: { bg.border.color = borderColor } + + onCurrentIndexChanged: { + console.log(tag, uuid + " onCurrentIndexChanged: " + this.currentIndex) + } + } diff --git a/doric-Qt/example/doric/shader/slider/DoricSliderNode.cpp b/doric-Qt/example/doric/shader/slider/DoricSliderNode.cpp index d076206c..546f91ed 100644 --- a/doric-Qt/example/doric/shader/slider/DoricSliderNode.cpp +++ b/doric-Qt/example/doric/shader/slider/DoricSliderNode.cpp @@ -67,6 +67,10 @@ void DoricSliderNode::afterBlended(QJsonValue prop) { QJsonDocument document = QJsonDocument::fromJson(jsValueString.toUtf8()); QJsonArray jsValue = document.array(); + QQmlListProperty contentChildren = + qvariant_cast>( + mView->property("contentChildren")); + for (int i = 0; i != jsValue.size(); i++) { QJsonValue model = jsValue.at(i); QString id = model["id"].toString(); @@ -77,7 +81,7 @@ void DoricSliderNode::afterBlended(QJsonValue prop) { newNode->init(this); this->childNodes.append((DoricSlideItemNode *)newNode); - newNode->getNodeView()->setParentItem(mView); + contentChildren.append(&contentChildren, newNode->getNodeView()); newNode->blend(model["props"]); }