summaryrefslogtreecommitdiffstats
path: root/doc/src/examples/quickstart.qdoc
blob: e814310b2889675c27632d568323fdcea1025830 (plain)
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
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
/****************************************************************************
**
** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**
** This file is part of the documentation of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:FDL$
** No Commercial Usage
** This file contains pre-release code and may not be distributed.
** You may use this file in accordance with the terms and conditions
** contained in the Technology Preview License Agreement accompanying
** this package.
**
** GNU Free Documentation License
** Alternatively, this file may be used under the terms of the GNU Free
** Documentation License version 1.3 as published by the Free Software
** Foundation and appearing in the file included in the packaging of this
** file.
**
** If you have questions regarding the use of this file, please contact
** Nokia at qt-info@nokia.com.
** $QT_END_LICENSE$
**
****************************************************************************/

/*!
\example quickstart

\title Quickstart guide

The following steps outline how to make a simple
"hello world" like application that uses Qt Mobility.
It is assumed that Qt Mobility has been
successfully built and environment variables have been set
as per \l {Installation Guide}.

One can start using QtMobility with 3 simple steps.
\list 1
    \o Include the appropriate headers
    \o Use the QTM_USE_NAMESPACE macro (defined in qmobilityglobal.h but implicitly included from any QtMobility header)
    \o Declare the usage of QtMobility
       and appropriate API(s) in the project(.pro) file
\endlist

Steps 1 and 2 are shown in the example below:
\snippet quickstart/main.cpp 0

This example uses the QSystemInfo headers to print out the
system's current country code.  All the domain APIs are wrapped
within a Qt Mobility namespace and thus developers
need to use the QTM_USE_NAMESPACE macro.

In step 3, to specify that our project is using
System Information we declare in the project file:

\snippet quickstart/quickstart.pro 0

The project file states that the application uses Qt Mobility and that it requires the
System Information API. By adding \c mobility to \c CONFIG qmake finds
the \c {mobility.prf} file in \c{$QTDIR/mkspecs/features} and includes it when
processing the current project file. \c{mobility.prf} is generated when running
the QtMobility configure script and points qmake to the relevant include and prefix
paths and ensures that deployment and package dependencies are set. The \c MOBILITY variable itself is part of \c {mobility.prf} and is used to
determine the QtMobility library the current project should link to (in this example the SystemInfo library).

Each QtMobility API has its corresponding value which has to be added to \c MOBILITY. The subsequent table lists the APIs and the
corresponding values that can be assigned to \c MOBILITY.

\table
\header
    \o Domain
    \o Value
\row
    \o \l {Bearer Management}
    \o bearer
\row
    \o \l {Contacts}
    \o contacts
\row
    \o \l {Location}
    \o location
\row
    \o \l {Multimedia}
    \o multimedia
\row
    \o \l {Messaging}
    \o messaging
\row
    \o \l {Publish And Subscribe}
    \o publishsubscribe
\row
    \o \l {Qt Service Framework} {Service Framework}
    \o serviceframework
\row
    \o \l {Sensor}{Sensors}
    \o sensors
\row
    \o \l {System Information}
    \o systeminfo
\row
    \o \l {Versit}{Versit}
    \o versit
\row
    \o \l {Document Gallery}
    \o gallery
\row
    \o \l {Organizer}
    \o organizer
\row
    \o \l {Feedback}{Tactile Feedback}
    \o feedback
\endtable

In addition the Mobility version and installed modules can be checked from within qmake project files. The associated module name for such tests is the same as above:

\code
    load(mobilityconfig)
    contains(MOBILITY_VERSION, 1.1.1) {
        message(Mobility 1.1.1 detected)
    }
    contains(MOBILITY_CONFIG, contacts) {
        message(Contacts API available)
        CONFIG+=mobility
        MOBILITY+=contacts
    } else {
        message(Contacts API not available)
    }
\endcode

When developing on Symbian we will also need to add the required capabilites to the project file in order to satisfy the Symbian security model.
This can be achieved with a line such as the following:

\code
    TARGET.CAPABILITY = CAPABILITY_A CABAPILITY_B
\endcode

CAPABILITY_A and CAPABILITY_B are place holders for the appropriate Symbian
capabilities. A complete list of all Symbian capabilities and their availability
to application developers can be found in the
\l {http://wiki.forum.nokia.com/index.php/Capabilities}{Forum Nokia Symbian capability documentation}.

The subsequent table provides an overview of possibily required security tokens for each QtMobility library.
Note that not all tokens are always required when using a particular API. The exact list depends
on which parts of an API is utilized by an application.

\table
\header
    \o Domain
    \o Symbian Capabilities
    \o Harmattan Tokens
\row
    \o \l {Bearer Management}
    \o ReadUserData NetworkServices (NetworkControl for QNetworkSession::stop())
    \o No token requirements known at this stage.
\row
    \o \l {Connectivity}{Connectivity - NFC}
    \o LocalServices
    \o No token requirements known at this stage.
\row
    \o \l {Connectivity}{Connectivity - Bluetooth} 
    \o LocalServices NetworkServices (ReadDeviceData WriteDeviceData for Pairing control)
    \o No token requirements known at this stage.
\row
    \o \l {Contacts}
    \o ReadUserData WriteUserData
    \o TrackerReadAccess TrackerWriteAccess GRP::metadata-users
\row
    \o \l {Location}
    \o Location LocalServices ReadUserData WriteUserData ReadDeviceData WriteDeviceData NetworkServices
    \o Location TrackerReadAccess TrackerWriteAccess
\row
    \o \l {Multimedia}
    \o UserEnvironment ReadUserData WriteUserData ReadDeviceData WriteDeviceData
    \o No token requirements known at this stage.
\row
    \o \l {Messaging}
    \o LocalServices ReadUserData WriteUserData NetworkServices UserEnvironment ReadDeviceData WriteDeviceData
    \o Cellular TrackerReadAccess
\row
    \o \l {Publish And Subscribe}
    \o Capability depends on P&S value being read/written. API itself doesn't require any capability.
    \o No token requirements known at this stage.
\row
    \o \l {Qt Service Framework} {Service Framework}
    \o No capabilities requried by itself, the plugins may have capability requirements.
    \o No token requirements known at this stage.
\row
    \o \l {Sensor}
    \o ReadDeviceData
    \o No token requirements known at this stage.
\row
    \o \l {System Information}
    \o LocalServices ReadUserData WriteUserData NetworkServices UserEnvironment Location ReadDeviceData
    \o mce::TKLockControl mce::DeviceModeControl
\row
    \o \l {Versit}
    \o No additional capabilities required.
    \o No token requirements known at this stage.
\row
    \o \l {Document Gallery}
    \o ReadDeviceData WriteDeviceData
    \o TrackerReadAccess TrackerWriteAccess
\row
    \o \l {Organizer}
    \o ReadUserData WriteUserData
    \o TrackerReadAccess TrackerWriteAccess GRP::calendar GRP::metadata-users
\row
    \o \l {Feedback}{Tactile Feedback}
    \o No capabilities at this stage.
    \o No token requirements known at this stage.
\endtable

The complete list of all Symbian capabilities and how they can be obtained can
be found at \l {http://wiki.forum.nokia.com/index.php/Capabilities}{Forum Nokia Symbian capability documentation}.

And we're done.  If you are using the command line simply
enter:
\code
    qmake
    make //or nmake on Windows
\endcode

to generate the executable which can then be run.

If you are developing for Symbian, to make a debug build for the emulator run:
\code
    qmake
    make debug-winscw
\endcode
This assumes that qmake is in your %PATH% and Qt has been built for the emulator already.


To make a release build and SIS package for a device run:
\code
    qmake
    make release-gcce
    make sis
\endcode

For further details on how to build applications for
Symbian see \l {http://qt.nokia.com/doc/4.6/symbian-with-qt-introduction.html}
{The Symbian Platform - Introduction to Qt} and \l {http://wiki.forum.nokia.com/index.php/Category:Qt_for_Symbian}
{Qt for Symbian}
*/