diff options
author | Warwick Allison <warwick.allison@nokia.com> | 2010-04-29 00:32:25 (GMT) |
---|---|---|
committer | Warwick Allison <warwick.allison@nokia.com> | 2010-04-29 00:32:25 (GMT) |
commit | a7ace40338145184ca490d1544c1171b56852617 (patch) | |
tree | 5ac30db7f42f5b706d1de2f645783a8e8c7805a7 /doc/src/snippets/declarative/componentCreation.js | |
parent | 44708167042e95ab4b5cfef8a19a9ab4f9484a71 (diff) | |
parent | efab34ea95560db007b1a75cce63cf8f6431a683 (diff) | |
download | Qt-a7ace40338145184ca490d1544c1171b56852617.zip Qt-a7ace40338145184ca490d1544c1171b56852617.tar.gz Qt-a7ace40338145184ca490d1544c1171b56852617.tar.bz2 |
Merge branch '4.7' of scm.dev.nokia.troll.no:qt/qt-qml into 4.7
Diffstat (limited to 'doc/src/snippets/declarative/componentCreation.js')
-rw-r--r-- | doc/src/snippets/declarative/componentCreation.js | 57 |
1 files changed, 57 insertions, 0 deletions
diff --git a/doc/src/snippets/declarative/componentCreation.js b/doc/src/snippets/declarative/componentCreation.js new file mode 100644 index 0000000..be3e4d6 --- /dev/null +++ b/doc/src/snippets/declarative/componentCreation.js @@ -0,0 +1,57 @@ +//![0] +var component; +var sprite; + +function finishCreation() { + if (component.isReady) { + sprite = component.createObject(); + if (sprite == null) { + // Error Handling + } else { + sprite.parent = appWindow; + sprite.x = 100; + sprite.y = 100; + // ... + } + } else if (component.isError()) { + // Error Handling + console.log("Error loading component:", component.errorsString()); + } +} +//![0] + +//![1] +function createSpriteObjects() { +//![1] + + //![2] + component = Qt.createComponent("Sprite.qml"); + if (component.isReady) + finishCreation(); + else + component.statusChanged.connect(finishCreation); + //![2] + + //![3] + component = Qt.createComponent("Sprite.qml"); + sprite = component.createObject(); + + if (sprite == null) { + // Error Handling + console.log("Error loading component:", component.errorsString()); + } else { + sprite.parent = appWindow; + sprite.x = 100; + sprite.y = 100; + // ... + } + //![3] + +//![4] +} +//![4] + +//![5] +createSpriteObjects(); +//![5] + |