diff options
Diffstat (limited to 'doc/src/declarative')
-rw-r--r-- | doc/src/declarative/network.qdoc | 81 | ||||
-rw-r--r-- | doc/src/declarative/qmlformat.qdoc | 4 |
2 files changed, 81 insertions, 4 deletions
diff --git a/doc/src/declarative/network.qdoc b/doc/src/declarative/network.qdoc index 3d75706..da4495f 100644 --- a/doc/src/declarative/network.qdoc +++ b/doc/src/declarative/network.qdoc @@ -43,11 +43,84 @@ \page qmlnetwork.html \title Network Transparency +QML supports network transparency by using URLs (rather than file names) for all +references from a QML document to other content. Since a \i relative URL is the same +as a relative file, development of QML on regular file systems remains simple. + +\section1 Accessing Network Reesources from QML + +Whenever an object has a property of type URL (QUrl), assigning a string to that +property will actually assign an absolute URL - by resolving the string against +the URL of the document where the string is used. + +For example, consider this content in \c{http://example.com/mystuff/test.qml}: + +\code +Image { + source: "images/logo.png" +} +\endcode + +The \l Image source property will be assigned \c{http://example.com/mystuff/images/logo.png}, +but while the QML is being developed, in say \c C:\User\Fred\Documents\MyStuff\test.qml, it will be assigned +\c C:\User\Fred\Documents\MyStuff\images\logo.png. + +Network transparency is supported throughout QML: + +\list +\o Types - if the \c test.qml file above used "Hello { }", that would refer to \c http://example.com/mystuff/Hello.qml +\o Scripts - the \c source property of \l Script is a URL +\o Images - the \c source property of \l Image and similar types is a URL +\o Fonts - the \c source property of FontLoader is a URL +\o WebViews - the \c url property of WebView may be assigned a relative URL string +\endlist + +Because of the declarative nature of QML and the asynchronous nature of network resources, +objects which reference network resource generally change state as the network resource loads. +For example, an Image with a network source will initially have +a \c width and \c height of 0, a \c status of \c Loading, and a \c progress of 0.0. +While the content loads, the \c progress will increase until +the content is fully loaded from the network, +at which point the \c width and \c height become the content size, the \c status becomes \c Ready, and the \c progress reaches 1.0. +Applications can bind to these changing states to provide visual progress indicators where appropriate, or simply +bind to the \c width and \c height as if the content was a local file, adapting as those bound values change. + +Note that when objects reference local files they immediately have the \c Ready status, but applications wishing +to remain network transparent should not rely on this. Future versions of QML may also use asynchronous local file I/O +to improve performance. + +\section1 Limitations + +The \c import statement only works network transparently if it has an "as" clause. + \list -\o Documents and script blocks can be fetched transparently over the network (blocking) -\o Images, fonts can be fetched transparently over the network (non-blocking) -\o Configuring the network access manager -\o Relative URL resolution from ECMAScript/QML +\o \c{import "dir"} only works on local file systems +\o \c{import libraryUri} only works on local file systems +\o \c{import "dir" as D} works network transparently +\o \c{import libraryUrl as U} works network transparently \endlist +\section1 Configuring the Network Access Manager + +All network access from QML is managed by a QNetworkAccessManager set on the QmlEngine which executes the QML. +By default, this is an unmodified Qt QNetworkAccessManager. You may set a different manager using +QmlEngine::setNetworkAccessManager() as appropriate for the policies of your application. +For eample, the \l qmlviewer tool sets a new QNetworkAccessManager which +trusts HTTP Expiry headers to avoid network cache checks, allows HTTP Pipelining, adds a persistent HTTP CookieJar, +a simple disk cache, and supports proxy settings. + +\section1 QRC Resources + +One of the URL schemes built into Qt is the "qrc" scheme. This allows content to be compiled into +the executable using \l{The Qt Resource System}. Using this, an executable can reference QML content +that is compiled into the executable: + +\code + QmlView *canvas = new QmlView; + canvas->setUrl(QUrl("qrc:/dial.qml")); +\endcode + +The content itself can then use relative URLs, and so be transparently unaware that the content is +compiled into the executable. + */ diff --git a/doc/src/declarative/qmlformat.qdoc b/doc/src/declarative/qmlformat.qdoc index be1afa4..72bbe40 100644 --- a/doc/src/declarative/qmlformat.qdoc +++ b/doc/src/declarative/qmlformat.qdoc @@ -192,6 +192,10 @@ different property bindings. \section1 Syntax +\section2 Encoding + +QML files are always encoded in UTF-8 format. + \section2 Commenting The commenting rules in QML are the same as for ECMAScript. Both \e {MultiLineComment} blocks and \e {SingleLineComment}'s are supported. |