File: qdeclarativeglobalobject.html

package info (click to toggle)
qt4-x11 4%3A4.8.2%2Bdfsg-11
  • links: PTS, VCS
  • area: main
  • in suites: wheezy
  • size: 701,696 kB
  • sloc: cpp: 2,686,179; ansic: 375,485; python: 25,859; sh: 19,349; xml: 17,091; perl: 14,765; yacc: 5,383; asm: 5,038; makefile: 1,259; lex: 555; ruby: 526; objc: 347; cs: 112; pascal: 112; php: 54; sed: 34
file content (174 lines) | stat: -rw-r--r-- 10,296 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en_US" lang="en_US">
<head>
  <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<!-- globalobject.qdoc -->
  <title>Qt 4.8: QML Global Object</title>
  <link rel="stylesheet" type="text/css" href="style/offline.css" />
</head>
<body>
<div class="header" id="qtdocheader">
  <div class="content"> 
    <a href="index.html" class="qtref"><span>Qt Reference Documentation</span></a>
  </div>
  <div class="breadcrumb toolblock">
    <ul>
      <li class="first"><a href="index.html">Home</a></li>
      <!--  Breadcrumbs go here -->
<li>QML Global Object</li>
    </ul>
  </div>
</div>
<div class="content mainContent">
<div class="toc">
<h3><a name="toc">Contents</a></h3>
<ul>
<li class="level1"><a href="#qt-object">Qt Object</a></li>
<li class="level1"><a href="#xmlhttprequest">XMLHttpRequest</a></li>
<li class="level1"><a href="#offline-storage-api">Offline Storage API</a></li>
<li class="level2"><a href="#database-api">Database API</a></li>
<li class="level3"><a href="#db-opendatabasesync-identifier-version-description-estimated-size-callback-db">db = openDatabaseSync(identifier, version, description, estimated_size, callback(db))</a></li>
<li class="level3"><a href="#db-changeversion-from-to-callback-tx">db.changeVersion(from, to, callback(tx))</a></li>
<li class="level3"><a href="#db-transaction-callback-tx">db.transaction(callback(tx))</a></li>
<li class="level3"><a href="#db-readtransaction-callback-tx">db.readTransaction(callback(tx))</a></li>
<li class="level3"><a href="#results-tx-executesql-statement-values">results = tx.executeSql(statement, values)</a></li>
<li class="level1"><a href="#logging">Logging</a></li>
</ul>
</div>
<h1 class="title">QML Global Object</h1>
<span class="subtitle"></span>
<!-- $$$qdeclarativeglobalobject.html-description -->
<div class="descr"> <a name="details"></a>
<p>Contains all the properties of the JavaScript global object, plus:</p>
<a name="qt-object"></a>
<h2>Qt Object</h2>
<p>The <a href="qml-qt.html#qmlglobalqtobject">Qt object</a> provides useful enums and functions from Qt, for use in all QML files.</p>
<a name="xmlhttprequest"></a>
<h2>XMLHttpRequest</h2>
<a name="xmlhttprequest"></a><p>QML script supports the <a href="#xmlhttprequest">XMLHttpRequest</a> object, which can be used to asynchronously obtain data from over a network.</p>
<p>The <a href="#xmlhttprequest">XMLHttpRequest</a> API implements the same <a href="http://www.w3.org/TR/XMLHttpRequest/">W3C standard</a> as many popular web browsers with following exceptions:</p>
<ul>
<li>QML's <a href="#xmlhttprequest">XMLHttpRequest</a> does not enforce the same origin policy.</li>
<li>QML's <a href="#xmlhttprequest">XMLHttpRequest</a> does not support <i>synchronous</i> requests.</li>
</ul>
<p>Additionally, the <tt>responseXML</tt> XML DOM tree currently supported by QML is a reduced subset of the <a href="http://www.w3.org/TR/DOM-Level-3-Core/">DOM Level 3 Core</a> API supported in a web browser. The following objects and properties are supported by the QML implementation:</p>
<table class="generic">
<thead><tr class="qt-style"><th ><b>Node</b></th><th ><b>Document</b></th><th ><b>Element</b></th><th ><b>Attr</b></th><th ><b>CharacterData</b></th><th ><b>Text</b></th></tr></thead>
<tr valign="top" class="odd"><td ><ul>
<li>nodeName</li>
<li>nodeValue</li>
<li>nodeType</li>
<li>parentNode</li>
<li>childNodes</li>
<li>firstChild</li>
<li>lastChild</li>
<li>previousSibling</li>
<li>nextSibling</li>
<li>attributes</li>
</ul>
</td><td ><ul>
<li>xmlVersion</li>
<li>xmlEncoding</li>
<li>xmlStandalone</li>
<li>documentElement</li>
</ul>
</td><td ><ul>
<li>tagName</li>
</ul>
</td><td ><ul>
<li>name</li>
<li>value</li>
<li>ownerElement</li>
</ul>
</td><td ><ul>
<li>data</li>
<li>length</li>
</ul>
</td><td ><ul>
<li>isElementContentWhitespace</li>
<li>wholeText</li>
</ul>
</td></tr>
</table>
<p>The <a href="declarative-xml-xmlhttprequest.html">XMLHttpRequest example</a> demonstrates how to use the <a href="#xmlhttprequest">XMLHttpRequest</a> object to make a request and read the response headers.</p>
<a name="offline-storage-api"></a>
<h2>Offline Storage API</h2>
<a name="database-api"></a>
<h3>Database API</h3>
<p>The <tt>openDatabaseSync()</tt> and related functions provide the ability to access local offline storage in an SQL database.</p>
<p>These databases are user-specific and QML-specific, but accessible to all QML applications. They are stored in the <tt>Databases</tt> subdirectory of <a href="qdeclarativeengine.html#offlineStoragePath-prop">QDeclarativeEngine::offlineStoragePath</a>(), currently as SQLite databases.</p>
<p>The API can be used from JavaScript functions in your QML:</p>
<pre class="qml"></pre>
<p>The API conforms to the Synchronous API of the HTML5 Web Database API, <a href="http://www.w3.org/TR/2009/WD-webdatabase-20091029/">W3C Working Draft 29 October 2009</a>.</p>
<p>The <a href="declarative-sqllocalstorage.html">SQL Local Storage example</a> demonstrates the basics of using the Offline Storage API.</p>
<a name="db-opendatabasesync-identifier-version-description-estimated-size-callback-db"></a>
<h4>db = openDatabaseSync(identifier, version, description, estimated_size, callback(db))</h4>
<p>Returns the database identified by <i>identifier</i>. If the database does not already exist, it is created, and the function <i>callback</i> is called with the database as a parameter. <i>description</i> and <i>estimated_size</i> are written to the INI file (described below), but are otherwise currently unused.</p>
<p>May throw exception with code property SQLException.DATABASE_ERR, or SQLException.VERSION_ERR.</p>
<p>When a database is first created, an INI file is also created specifying its characteristics:</p>
<table class="generic">
<thead><tr class="qt-style"><th ><b>Key</b></th><th ><b>Value</b></th></tr></thead>
<tr valign="top" class="odd"><td >Name</td><td >The name of the database passed to <tt>openDatabase()</tt></td></tr>
<tr valign="top" class="even"><td >Version</td><td >The version of the database passed to <tt>openDatabase()</tt></td></tr>
<tr valign="top" class="odd"><td >Description</td><td >The description of the database passed to <tt>openDatabase()</tt></td></tr>
<tr valign="top" class="even"><td >EstimatedSize</td><td >The estimated size (in bytes) of the database passed to <tt>openDatabase()</tt></td></tr>
<tr valign="top" class="odd"><td >Driver</td><td >Currently &quot;QSQLITE&quot;</td></tr>
</table>
<p>This data can be used by application tools.</p>
<a name="db-changeversion-from-to-callback-tx"></a>
<h4>db.changeVersion(from, to, callback(tx))</h4>
<p>This method allows you to perform a <i>Scheme Upgrade</i>.</p>
<p>If the current version of <i>db</i> is not <i>from</i>, then an exception is thrown.</p>
<p>Otherwise, a database transaction is created and passed to <i>callback</i>. In this function, you can call <i>executeSql</i> on <i>tx</i> to upgrade the database.</p>
<p>May throw exception with code property SQLException.DATABASE_ERR or SQLException.UNKNOWN_ERR.</p>
<a name="db-transaction-callback-tx"></a>
<h4>db.transaction(callback(tx))</h4>
<p>This method creates a read/write transaction and passed to <i>callback</i>. In this function, you can call <i>executeSql</i> on <i>tx</i> to read and modify the database.</p>
<p>If the callback throws exceptions, the transaction is rolled back.</p>
<a name="db-readtransaction-callback-tx"></a>
<h4>db.readTransaction(callback(tx))</h4>
<p>This method creates a read-only transaction and passed to <i>callback</i>. In this function, you can call <i>executeSql</i> on <i>tx</i> to read the database (with SELECT statements).</p>
<a name="results-tx-executesql-statement-values"></a>
<h4>results = tx.executeSql(statement, values)</h4>
<p>This method executes a SQL <i>statement</i>, binding the list of <i>values</i> to SQL positional parameters (&quot;?&quot;).</p>
<p>It returns a results object, with the following properties:</p>
<table class="generic">
<thead><tr class="qt-style"><th ><b>Type</b></th><th ><b>Property</b></th><th ><b>Value</b></th><th ><b>Applicability</b></th></tr></thead>
<tr valign="top" class="odd"><td >int</td><td >rows.length</td><td >The number of rows in the result</td><td >SELECT</td></tr>
<tr valign="top" class="even"><td >var</td><td >rows.item(i)</td><td >Function that returns row <i>i</i> of the result</td><td >SELECT</td></tr>
<tr valign="top" class="odd"><td >int</td><td >rowsAffected</td><td >The number of rows affected by a modification</td><td >UPDATE, DELETE</td></tr>
<tr valign="top" class="even"><td >string</td><td >insertId</td><td >The id of the row inserted</td><td >INSERT</td></tr>
</table>
<p>May throw exception with code property SQLException.DATABASE_ERR, SQLException.SYNTAX_ERR, or SQLException.UNKNOWN_ERR.</p>
<a name="logging"></a>
<h2>Logging</h2>
<p><tt>console.log()</tt> and <tt>console.debug()</tt> can be used to print information to the console. See <a href="qdeclarativedebugging.html">Debugging QML</a> for more information.</p>
</div>
<!-- @@@qdeclarativeglobalobject.html -->
  <div class="ft">
    <span></span>
  </div>
</div> 
<div class="footer">
    <p>
      <acronym title="Copyright">&copy;</acronym> 2012 Nokia Corporation and/or its
      subsidiaries. Documentation contributions included herein are the copyrights of
      their respective owners.</p>
    <br />
    <p>
      The documentation provided herein is licensed under the terms of the
      <a href="http://www.gnu.org/licenses/fdl.html">GNU Free Documentation
      License version 1.3</a> as published by the Free Software Foundation.</p>
    <p>
      Documentation sources may be obtained from <a href="http://www.qt-project.org">
      www.qt-project.org</a>.</p>
    <br />
    <p>
      Nokia, Qt and their respective logos are trademarks of Nokia Corporation 
      in Finland and/or other countries worldwide. All other trademarks are property
      of their respective owners. <a title="Privacy Policy"
      href="http://en.gitorious.org/privacy_policy/">Privacy Policy</a></p>
</div>
</body>
</html>