diff options
author | Martin Smith <msmith@trolltech.com> | 2010-05-12 13:12:13 (GMT) |
---|---|---|
committer | Martin Smith <msmith@trolltech.com> | 2010-05-12 13:12:13 (GMT) |
commit | bd11cdf472674af3b00d7d64c64023adbf5ee725 (patch) | |
tree | 99eb333a12f7e0d109b9ce9ff51120c612669d7a /doc/src/snippets/declarative/componentCreation.js | |
parent | 50fa9ebe8fc0e7eca7536a8663c86cd6b98b2c04 (diff) | |
parent | 0ebc9783d8ca0c4b27208bbc002c53c52c19ab4c (diff) | |
download | Qt-bd11cdf472674af3b00d7d64c64023adbf5ee725.zip Qt-bd11cdf472674af3b00d7d64c64023adbf5ee725.tar.gz Qt-bd11cdf472674af3b00d7d64c64023adbf5ee725.tar.bz2 |
Merge branch '4.7' of git@scm.dev.nokia.troll.no:qt/oslo-staging-1 into 4.7
Diffstat (limited to 'doc/src/snippets/declarative/componentCreation.js')
-rw-r--r-- | doc/src/snippets/declarative/componentCreation.js | 47 |
1 files changed, 47 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..f6fb379 --- /dev/null +++ b/doc/src/snippets/declarative/componentCreation.js @@ -0,0 +1,47 @@ +//![0] +var component; +var sprite; + +function finishCreation() { + if (component.status == Component.Ready) { + sprite = component.createObject(appWindow); + if (sprite == null) { + // Error Handling + } else { + sprite.x = 100; + sprite.y = 100; + // ... + } + } else if (component.status == Component.Error) { + // Error Handling + console.log("Error loading component:", component.errorsString()); + } +} +//![0] + +function createSpriteObjects() { + +//![1] +component = Qt.createComponent("Sprite.qml"); +if (component.status == Component.Ready) + finishCreation(); +else + component.statusChanged.connect(finishCreation); +//![1] + +//![2] +component = Qt.createComponent("Sprite.qml"); +sprite = component.createObject(appWindow); + +if (sprite == null) { + // Error Handling + console.log("Error loading component:", component.errorsString()); +} else { + sprite.x = 100; + sprite.y = 100; + // ... +} +//![2] + +} + |