source: trunk/doc/src/declarative/globalobject.qdoc@ 846

Last change on this file since 846 was 846, checked in by Dmitry A. Kuminov, 14 years ago

trunk: Merged in qt 4.7.2 sources from branches/vendor/nokia/qt.

File size: 6.3 KB
Line 
1/****************************************************************************
2**
3** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
4** All rights reserved.
5** Contact: Nokia Corporation ([email protected])
6**
7** This file is part of the documentation of the Qt Toolkit.
8**
9** $QT_BEGIN_LICENSE:FDL$
10** Commercial Usage
11** Licensees holding valid Qt Commercial licenses may use this file in
12** accordance with the Qt Commercial License Agreement provided with the
13** Software or, alternatively, in accordance with the terms contained in a
14** written agreement between you and Nokia.
15**
16** GNU Free Documentation License
17** Alternatively, this file may be used under the terms of the GNU Free
18** Documentation License version 1.3 as published by the Free Software
19** Foundation and appearing in the file included in the packaging of this
20** file.
21**
22** If you have questions regarding the use of this file, please contact
23** Nokia at [email protected].
24** $QT_END_LICENSE$
25**
26****************************************************************************/
27
28/*!
29\page qdeclarativeglobalobject.html
30\title QML Global Object
31
32Contains all the properties of the JavaScript global object, plus:
33
34\tableofcontents
35
36\section1 Qt Object
37
38The \l{QmlGlobalQtObject}{Qt object} provides useful enums and functions from Qt, for use in all QML
39files.
40
41\section1 XMLHttpRequest
42
43\target XMLHttpRequest
44
45QML script supports the XMLHttpRequest object, which can be used to asynchronously obtain
46data from over a network.
47
48The XMLHttpRequest API implements the same \l {http://www.w3.org/TR/XMLHttpRequest/}{W3C standard}
49as many popular web browsers with following exceptions:
50\list
51\i QML's XMLHttpRequest does not enforce the same origin policty.
52\i QML's XMLHttpRequest does not support \e synchronous requests.
53\endlist
54
55Additionally, the \c responseXML XML DOM tree currently supported by QML is a reduced subset
56of the \l {http://www.w3.org/TR/DOM-Level-3-Core/}{DOM Level 3 Core} API supported in a web
57browser. The following objects and properties are supported by the QML implementation:
58
59\table
60\header
61\o \bold {Node}
62\o \bold {Document}
63\o \bold {Element}
64\o \bold {Attr}
65\o \bold {CharacterData}
66\o \bold {Text}
67
68\row
69\o
70\list
71\o nodeName
72\o nodeValue
73\o nodeType
74\o parentNode
75\o childNodes
76\o firstChild
77\o lastChild
78\o previousSibling
79\o nextSibling
80\o attribtes
81\endlist
82
83\o
84\list
85\o xmlVersion
86\o xmlEncoding
87\o xmlStandalone
88\o documentElement
89\endlist
90
91\o
92\list
93\o tagName
94\endlist
95
96\o
97\list
98\o name
99\o value
100\o ownerElement
101\endlist
102
103\o
104\list
105\o data
106\o length
107\endlist
108
109\o
110\list
111\o isElementContentWhitespace
112\o wholeText
113\endlist
114
115\endtable
116
117The \l{declarative/xml/xmlhttprequest}{XMLHttpRequest example} demonstrates how to
118use the XMLHttpRequest object to make a request and read the response headers.
119
120\section1 Offline Storage API
121
122\section2 Database API
123
124The \c openDatabaseSync() and related functions
125provide the ability to access local offline storage in an SQL database.
126
127These databases are user-specific and QML-specific, but accessible to all QML applications.
128They are stored in the \c Databases subdirectory
129of QDeclarativeEngine::offlineStoragePath(), currently as SQLite databases.
130
131The API can be used from JavaScript functions in your QML:
132
133\snippet declarative/sqllocalstorage/hello.qml 0
134
135The API conforms to the Synchronous API of the HTML5 Web Database API,
136\link http://www.w3.org/TR/2009/WD-webdatabase-20091029/ W3C Working Draft 29 October 2009\endlink.
137
138The \l{declarative/sqllocalstorage}{SQL Local Storage example} demonstrates the basics of
139using the Offline Storage API.
140
141\section3 db = openDatabaseSync(identifier, version, description, estimated_size, callback(db))
142
143Returns the database identified by \e identifier. If the database does not already exist, it
144is created with the properties \e description and \e estimated_size and the function \e callback
145is called with the database as a parameter.
146
147May throw exception with code property SQLException.DATABASE_ERR, or SQLException.VERSION_ERR.
148
149When a database is first created, an INI file is also created specifying its characteristics:
150
151\table
152\header \o \bold {Key} \o \bold {Value}
153\row \o Name \o The name of the database passed to \c openDatabase()
154\row \o Version \o The version of the database passed to \c openDatabase()
155\row \o Description \o The description of the database passed to \c openDatabase()
156\row \o EstimatedSize \o The estimated size of the database passed to \c openDatabase()
157\row \o Driver \o Currently "QSQLITE"
158\endtable
159
160This data can be used by application tools.
161
162\section3 db.changeVersion(from, to, callback(tx))
163
164This method allows you to perform a \e{Scheme Upgrade}.
165
166If the current version of \e db is not \e from, then an exception is thrown.
167
168Otherwise, a database transaction is created and passed to \e callback. In this function,
169you can call \e executeSql on \e tx to upgrade the database.
170
171May throw exception with code property SQLException.DATABASE_ERR or SQLException.UNKNOWN_ERR.
172
173\section3 db.transaction(callback(tx))
174
175This method creates a read/write transaction and passed to \e callback. In this function,
176you can call \e executeSql on \e tx to read and modify the database.
177
178If the callback throws exceptions, the transaction is rolled back.
179
180\section3 db.readTransaction(callback(tx))
181
182This method creates a read-only transaction and passed to \e callback. In this function,
183you can call \e executeSql on \e tx to read the database (with SELECT statements).
184
185\section3 results = tx.executeSql(statement, values)
186
187This method executes a SQL \e statement, binding the list of \e values to SQL positional parameters ("?").
188
189It returns a results object, with the following properties:
190
191\table
192\header \o \bold {Type} \o \bold {Property} \o \bold {Value} \o \bold {Applicability}
193\row \o int \o rows.length \o The number of rows in the result \o SELECT
194\row \o var \o rows.item(i) \o Function that returns row \e i of the result \o SELECT
195\row \o int \o rowsAffected \o The number of rows affected by a modification \o UPDATE, DELETE
196\row \o string \o insertId \o The id of the row inserted \o INSERT
197\endtable
198
199May throw exception with code property SQLException.DATABASE_ERR, SQLException.SYNTAX_ERR, or SQLException.UNKNOWN_ERR.
200
201\section1 Logging
202
203\c console.log() and \c console.debug() can be used to print information
204to the console. See \l{Debugging QML} for more information.
205
206*/
Note: See TracBrowser for help on using the repository browser.