diff options
author | Alan Alpert <alan.alpert@nokia.com> | 2009-07-02 04:00:06 (GMT) |
---|---|---|
committer | Alan Alpert <alan.alpert@nokia.com> | 2009-07-02 04:00:06 (GMT) |
commit | 113d2b5d82736c503657f15a3ee56d4daf1829ed (patch) | |
tree | 8c2dcc3f0505724a28ac83747b02bb1b7bcae683 /examples/declarative | |
parent | 49c339cfebdab26e6239335a45ca9f3e852f254b (diff) | |
download | Qt-113d2b5d82736c503657f15a3ee56d4daf1829ed.zip Qt-113d2b5d82736c503657f15a3ee56d4daf1829ed.tar.gz Qt-113d2b5d82736c503657f15a3ee56d4daf1829ed.tar.bz2 |
Improve JS dynamic creation
Renamed evalQml to be consistent with us, not javascript.
Fixed bug where createComponent never had the right path.
createQmlObject (evalQml) now has a parent as a argument.
It also still has a bug where that parent doesnt get set properly,
although it is used as the creation context also.
Diffstat (limited to 'examples/declarative')
-rw-r--r-- | examples/declarative/dynamic/dynamic.js | 13 | ||||
-rw-r--r-- | examples/declarative/dynamic/dynamic.qml | 4 |
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; } |