![]() |
Home · All Classes · All Functions · Overviews |
The Script element provides a way to add JavaScript code snippets in QML. More...
The Script element is used to add convenient JavaScript "glue" methods to your Qt Declarative application or component.
An example:
Script { function debugMyComponent() { console.log(text.text); console.log(otherinterestingitem.property); } } MouseArea { onClicked: debugMyComponent() }
Note: While it is possible to use any JavaScript code within a Script element, it is recommended that the code be limited to defining functions. The Script element executes JavaScript as soon as it is specified, so when defining a component, this may be done before the execution context is fully specified. As a result, some properties or items may not be accessible. You can avoid this problem by limiting your JavaScript to defining functions that are only executed later once the context is fully defined.
See also JavaScript Blocks.
script : string |
default |
The JavaScript code to be executed.
source : url |
Specifies a source file containing JavaScript code. This can be used instead of providing inline JavaScript code in the Script element.
Copyright © 2010 Nokia Corporation and/or its subsidiary(-ies) | Trademarks | Qt 4.7.0 |