diff options
author | Qt Continuous Integration System <qt-info@nokia.com> | 2010-05-04 10:23:21 (GMT) |
---|---|---|
committer | Qt Continuous Integration System <qt-info@nokia.com> | 2010-05-04 10:23:21 (GMT) |
commit | 337dbd5391b4e2b1bd88918a46f3392df8fd1312 (patch) | |
tree | 0f065124c11ffbec256924e36baee2ba1fc0e069 /doc/src/snippets/declarative/componentCreation.js | |
parent | ffa103af9620998f47c632f4118e789bf7f1cde7 (diff) | |
parent | a5aadcea4c12c7926bf3b4d218ce476723cd7e10 (diff) | |
download | Qt-337dbd5391b4e2b1bd88918a46f3392df8fd1312.zip Qt-337dbd5391b4e2b1bd88918a46f3392df8fd1312.tar.gz Qt-337dbd5391b4e2b1bd88918a46f3392df8fd1312.tar.bz2 |
Merge branch '4.7' of scm.dev.nokia.troll.no:qt/qt-qml into 4.7-integration
* '4.7' of scm.dev.nokia.troll.no:qt/qt-qml: (74 commits)
Optimization for QDeclarativePaintedItem.
Update childrenRect when children are added or removed.
Optimize childrenRect.
Remove obsolete doc groupings.
Doc improvements
Remove QDeclarativeLoader::resizeMode
Don't create an anchors element so that we can check that there aren't any
Ensure eval and Function are in the correct scope
Add availableFonts.qml for fonts examples.
Add Qt.fontFamilies() method
Avoid regenerating PathView delegates needlessly
When a model delegate is released, remove it from the scene immediately.
Fix assignment of value types to javascript var.
More doc fixes
Make QDeclarativeParserStatus method pure virtual to encourage right code.
Doc fixes
Fix error string
Add QML value types for math3d types
Fix assert in qdeclarativepathview
Avoid divisions by zero in qdeclarativetimeline
...
Diffstat (limited to 'doc/src/snippets/declarative/componentCreation.js')
-rw-r--r-- | doc/src/snippets/declarative/componentCreation.js | 51 |
1 files changed, 51 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..be928f0 --- /dev/null +++ b/doc/src/snippets/declarative/componentCreation.js @@ -0,0 +1,51 @@ +//![0] +var component; +var sprite; + +function finishCreation() { + if (component.status == Component.Ready) { + sprite = component.createObject(); + if (sprite == null) { + // Error Handling + } else { + sprite.parent = appWindow; + 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(); + +if (sprite == null) { + // Error Handling + console.log("Error loading component:", component.errorsString()); +} else { + sprite.parent = appWindow; + sprite.x = 100; + sprite.y = 100; + // ... +} +//![2] + +} + +createSpriteObjects(); + |