summaryrefslogtreecommitdiffstats
path: root/examples
diff options
context:
space:
mode:
Diffstat (limited to 'examples')
-rw-r--r--examples/declarative/dynamic/dynamic.js13
-rw-r--r--examples/declarative/dynamic/dynamic.qml4
2 files changed, 10 insertions, 7 deletions
diff --git a/examples/declarative/dynamic/dynamic.js b/examples/declarative/dynamic/dynamic.js
index 6b483fd..5accc46 100644
--- a/examples/declarative/dynamic/dynamic.js
+++ b/examples/declarative/dynamic/dynamic.js
@@ -1,10 +1,10 @@
var dynamicObject = null;
var fourthBox = null;
-var component;
+var component = null;
var started = false;
-function createWithEvalQml(p) {
- return evalQml('Rect { color: "lightsteelblue"; width: 100;'
- + 'height: 100; id: newRect}','DynPart.qml');
+function createQml(p) {
+ return createQmlObject('Rect { color: "steelblue"; width: 100;'
+ + 'height: 100; id: newRect }',p,'DynPart.qml');
}
function destroyDynamicObject() {
@@ -29,7 +29,7 @@ function instantCreateWithComponent() {//Like create, but assumes instant readyn
}
function finishCreation(){
- if(component.isReady()){
+ if(component.isReady() && dynamicObject == null){
dynamicObject = component.createObject();
dynamicObject.parent = targetItem;
}else if(component.isError()){
@@ -40,6 +40,9 @@ function finishCreation(){
}
function createWithComponent(){
+ if(component!=null){
+ return finishCreation();
+ }
if(started!=false){
finishCreation();//Remakes if destroyed
return dynamicObject;
diff --git a/examples/declarative/dynamic/dynamic.qml b/examples/declarative/dynamic/dynamic.qml
index 3e0c12e..b9f3b35 100644
--- a/examples/declarative/dynamic/dynamic.qml
+++ b/examples/declarative/dynamic/dynamic.qml
@@ -13,9 +13,9 @@ Rect { id: page; width: 800; height: 800; color:"black"
MouseRegion { anchors.fill:parent; onClicked:
{
if(fourthBox == null) {
- a = createWithEvalQml();
+ a = createQml(targetItem2);
if(a!=null) {
- a.parent = targetItem2;
+ a.parent = targetItem2;//BUG: this should happen automatically
fourthBox = a;
extendStars = true;
}