diff options
author | Aaron Kennedy <aaron.kennedy@nokia.com> | 2010-06-22 03:12:49 (GMT) |
---|---|---|
committer | Aaron Kennedy <aaron.kennedy@nokia.com> | 2010-06-22 03:12:49 (GMT) |
commit | 800b1ad057d97f90555af3c94f08a935526373cf (patch) | |
tree | cdf0128ac175557464a9f101ebb35cd287c81845 /src/declarative/qml/qdeclarativeinclude.cpp | |
parent | 1b263458966dbf8aca5dc64218b726a74c4ff581 (diff) | |
download | Qt-800b1ad057d97f90555af3c94f08a935526373cf.zip Qt-800b1ad057d97f90555af3c94f08a935526373cf.tar.gz Qt-800b1ad057d97f90555af3c94f08a935526373cf.tar.bz2 |
Doc
Diffstat (limited to 'src/declarative/qml/qdeclarativeinclude.cpp')
-rw-r--r-- | src/declarative/qml/qdeclarativeinclude.cpp | 25 |
1 files changed, 24 insertions, 1 deletions
diff --git a/src/declarative/qml/qdeclarativeinclude.cpp b/src/declarative/qml/qdeclarativeinclude.cpp index 388f252..c29005a 100644 --- a/src/declarative/qml/qdeclarativeinclude.cpp +++ b/src/declarative/qml/qdeclarativeinclude.cpp @@ -172,6 +172,29 @@ void QDeclarativeInclude::callback(QScriptEngine *engine, QScriptValue &callback } } +/*! +\qmlmethod object Qt::include(url, callback) + +Include another JavaScript file. This method can only be used from within JavaScript files, +and not regular QML files. + +Qt.include() returns an object that describes the status of the operation. The object has +a single property, \c {status} that is set to one of the following values: + +\table +\header \o Symbol \o Value \o Description +\row \o result.OK \o 0 \o The include completed successfully. +\row \o result.LOADING \o 1 \o Data is being loaded from the network. +\row \o result.NETWORK_ERROR \o 2 \o A network error occurred while fetching the url. +\row \o result.EXCEPTION \o 3 \o A JavaScript exception occurred while executing the included code. +An additional \c exception property will be set in this case. +\endtable + +The return object's properties will be updated as the operation progresses. + +If provided, \a callback is invoked when the operation completes. The callback is passed +the same object as is returned from the Qt.include() call. +*/ QScriptValue QDeclarativeInclude::include(QScriptContext *ctxt, QScriptEngine *engine) { if (ctxt->argumentCount() == 0) @@ -184,7 +207,7 @@ QScriptValue QDeclarativeInclude::include(QScriptContext *ctxt, QScriptEngine *e return ctxt->throwError(QLatin1String("Qt.include(): Can only be called from JavaScript files")); QString urlString = ctxt->argument(0).toString(); - QUrl url(ctxt->argument(0).toString()); + QUrl url(urlString); if (url.isRelative()) { url = QUrl(contextUrl).resolved(url); urlString = url.toString(); |