QtQml.qtqml-javascript-qmlglobalobject
The QML JavaScript host environment implements the following host objects and functions. These are built in and can be used from any JavaScript code loaded in QML, without additional imports:
- The Qt object: This object is specific to QML, and provides helper methods and properties specific to the QML environment.
- qsTr(), qsTranslate(), qsTrId(), QT_TR_NOOP(), QT_TRANSLATE_NOOP(), and QT_TRID_NOOP() functions: These functions are specific to QML, and provide translation capabilities to the QML environment.
- gc() function: This function is specific to QML, and provides a way to manually trigger garbage collection.
- print() function: This function is specific to QML, and provides a simple way to output information to the console.
- The console object: This object implements a subset of the href="http://getfirebug.com/wiki/index.php/Console_API">FireBug Console API.
- XMLHttpRequest, DOMException: These objects implement a subset of the href="http://www.w3.org/TR/XMLHttpRequest/">W3C XMLHttpRequest specification.
XMLHttpRequest
The XMLHttpRequest object, which can be used to asynchronously obtain data from over a network.
The XMLHttpRequest API implements the same href="http://www.w3.org/TR/XMLHttpRequest/">W3C standard as many popular web browsers with following exceptions:
- QML's XMLHttpRequest does not enforce the same origin policy.
- QML's XMLHttpRequest does not support synchronous requests.
Additionally, the responseXML
XML DOM tree currently supported by QML is a reduced subset of the href="http://www.w3.org/TR/DOM-Level-3-Core/">DOM Level 3 Core API supported in a web browser. The following objects and properties are supported by the QML implementation:
Node | Document | Element | Attr | CharacterData | Text |
---|---|---|---|---|---|
|
|
|
|
|
|
The XMLHttpRequest example demonstrates how to use the XMLHttpRequest object to make a request and read the response headers.