Newer
Older
To add a Qt version:
\list 1
\o Select \gui{Qt Creator} > \gui Preferences... > \gui{Qt Versions}.
\o Click \inlineimage qtcreator-macosx-add.png
and enter the name of the version in \gui{Version Name}.
\o Enter the path to the qmake binary in \gui{Path to qmake}.
\image qtcreator-qt4-qtversions.png
\endlist

Leena Miettinen
committed
\section1 Adding External Libraries to a qmake Project
Through external libraries Qt Creator can support code completion and
syntax highlighting as if they were part of the current project or the Qt
library.
To add an external library:
\list 1
\o Open your project file (.pro) using the \gui Projects pane.
\o Follow the instructions at \l{http://doc.qt.nokia.com/4.7-snapshot/qmake-project-files.html#declaring-other-libraries}

Leena Miettinen
committed
{Declaring other Libraries}.
\endlist
Syntax completion and highlighting work once your project successfully
builds and links against the external library.
\previouspage quick-application-logic.html

Leena Miettinen
committed
\nextpage creator-building-targets.html
\title Building and Running Applications
Qt Creator provides support for building and running Qt applications for
desktop environment and mobile devices. When you install the Nokia Qt SDK,

Leena Miettinen
committed
the build and run settings for the Maemo and Symbian targets are

Leena Miettinen
committed
You can add a target if the necessary tool chain is installed on the
development PC and the Qt version is configured. Click
\inlineimage qtcreator-qt4-addbutton.png "Add Target button"
and select from a list of available
targets. To remove a target, select it and click
\inlineimage qtcreator-target-remove.png "Remove Target button"
.
You can select the targets and click the \gui Run button to build and
run the applications on the targets. You can click the \gui {Build All}
button to build all open projects, one after another.
To view and modify the settings for currently open projects, switch to the
The project pane consists of the following tabs:

Leena Miettinen
committed
\o \l{Building for Multiple Targets}{Targets}

Leena Miettinen
committed
\note If you have installed only one tool chain, the \gui Targets
tab is replaced by a \gui {Build and Run} tab.

Leena Miettinen
committed
\o \l{Specifying Editor Settings}{Editor Settings}
\o \l{Specifying Dependencies}{Dependencies}
Use the \gui Build and \gui Run buttons to switch between
the build and run settings for the active project.
If you have multiple projects open in Qt Creator, use
\gui{Select a Project} option at the top to navigate between different
project edits.

Leena Miettinen
committed
*/
/*!
\contentspage index.html
\previouspage creator-building-running.html
\page creator-building-targets.html
\nextpage creator-build-settings.html
\title Building for Multiple Targets
Different build configurations allow you to quickly switch between
different build settings. By default, Qt Creator creates \bold debug

Leena Miettinen
committed
\section1 Building for Desktop
\list 1
\o Select \gui Desktop as the target.
\o Click the \gui Run button.
\endlist

Leena Miettinen
committed
\section1 Building for Qt Simulator
You can use the Qt Simulator to test Qt applications that are intended
for mobile devices in an environment similar to that of the device. You
can change the information that the device has about its configuration
and environment.
\list 1
\o Select \gui {Qt Simulator} as the target.
\o Click the \gui Run button.
\endlist
For more information about using the Qt Simulator, see the
\l{http://doc.qt.nokia.com/qt-simulator-beta/index.html}{Qt Simulator Manual}.
\section1 Building for Maemo
\o Build and run the application for \l{Building for Qt Simulator}{Qt Simulator}.
\o Build and run the application for \l{Using the Maemo Emulator}{Maemo Emulator}.
\o Alternatively, you can build and run the application for a device:
\list 1
\o Set up the MADDE development environment and specify a connection
to the device. For more information, see
\l{Setting Up Development Environment for Maemo}.
\o Connect the device to the development PC.
\o Click the \gui Run button.
\endlist
\endlist
Qt Creator uses the compiler specified in the MADDE toolchain to
build the application.
Qt Creator generates an installation package, installs in on the device,
and executes it. The application views are displayed on the Nokia N900.
Command-line
output is visible in the Qt Creator \gui {Application Output} view.
\section2 Creating Installation Packages
When you build the application for the \gui{Maemo} target, Qt
Creator automatically generates a debian installation package
in the project folder. You can deliver the installation package to
users for installation on Maemo devices.
You can add other files to the installation package in the
\gui {Create package} step in the build configuration. Add files
to the \gui {Package contents} field. In \gui {Local File Path},
specify the location of the file on the development PC. In
\gui {Remote File Path}, specify the folder to install the file on
the device.
\image qtcreator-maemo-deb-package.png "Create installation package"
\section1 Building for Symbian
\list 1
\o Build and run the application for \l{Building for Qt Simulator}{Qt Simulator}.
\o If no problems are found, build and run the application for a device.
\o To test functionality that uses Symbian APIs, you can build and
run the application for Symbian Emulator.
\endlist
The build configuration for the \gui{Symbian Device} target
uses the GCCE tool chain by default. If you want to build
for the device using RVCT, select it in the \gui {Tool chain} field
in the \gui{General} section.

Leena Miettinen
committed
\section2 Building and Running for a Device
\list 1
\o Install the required software on the device. For more information, see
\l{Setting Up Development Environment for Symbian}.
\o Connect the device to the development PC through a USB cable.
The target selector displays a green check mark when a
device is connected.
\image qtcreator-qt4-symbian-device-connected.png
The tool tip of the target selector shows more details about the actual
2205
2206
2207
2208
2209
2210
2211
2212
2213
2214
2215
2216
2217
2218
2219
2220
2221
2222
2223
2224
2225
2226
2227
2228
2229
2230
2231
2232
2233
2234
2235
2236
2237
2238
2239
2240
2241
2242
2243
2244
2245
2246
2247
2248
2249
2250
2251
device that will be used when you run your application.
\o Start the \gui{App TRK} application on your device.
\o Click the \gui Run button.
\endlist
You can connect several devices to your development PC simultaneously.
In the details of the run configuration for the \gui{Symbian Device} target,
select the device to run your application on.
\section3 Creating Installation Packages
When you build the application for the \gui{Symbian Device} target, Qt
Creator automatically generates a Symbian installation system (SIS) file
in the project folder. You can deliver the installation file to users for
installation on Symbian devices.
Only installation files signed with a certificate and private key are
allowed to be installed onto Symbian devices. By default, Qt Creator
self-signs the installation file. This self-signing allows you to install
the application on a mobile device but places limits on what you can do
with the installation file, including:
\list
\o Self-signed applications cannot access the more sensitive
\l{Capabilities and Signing}{capabilities} of the mobile device.
\o Security warnings will be displayed when you install the self-signed
application on a mobile device.
\o Self-signed applications cannot be distributed commercially on Ovi
Store.
\endlist
To get around these limitations, you need to go through the Symbian Signed
process. The Symbian Signed organisation manages a public key
infrastructure to provide public authentication of the information in the
application signing certificates. Their security partner can validate your
certificate and give you a Publisher ID. Then, when you sign an
application, other people can be confident that the information in your
certificate is correct and that the application does actually come from you.
There are also options that do not require you to get a Publisher ID. For
more detail about how the Symbian Signed process works, see
\l{http://developer.symbian.org/wiki/index.php/Complete_Guide_To_Symbian_Signed}
{Complete Guide to Symbian Signed}.
When you have your own certificate and private key, you can specify them in

Leena Miettinen
committed
the \gui{Create SIS Package} step in your build configuration.
2253
2254
2255
2256
2257
2258
2259
2260
2261
2262
2263
2264
2265
2266
2267
2268
2269
2270
2271
2272
2273
2274
2275
2276
2277
2278
2279
2280
2281
2282
2283
2284
2285
2286
2287
2288
2289
2290
2291
2292
2293
2294
\image qtcreator-qt4-symbian-signing.png
\section3 Capabilities and Signing
Capabilities allow the Symbian platform to control access by applications to
the functionality provided by the platform APIs. Access to capabilities is
determined by the device configuration and how the application has been signed.
Symbian Signed offers the following signing options depending on the
capabilities that the application accesses:
\list
\o \bold{Express signed} for applications that access only user and system
capabilities.
\o \bold{Certified signed} for applications that access also restricted or
device manufacturer capabilities.
\note You need to request the rights to access device manufacturer
capabilities from the manufacturer.
\endlist
For more information about how to choose the appropriate signing option, see
\l{http://developer.symbian.org/wiki/index.php/Symbian_Signed_For_Distributing_Your_Application}{Symbian Signed For Distributing Your Application}.
If you select a signing option that does not allow the application to access
the defined capabilities, installing the application on mobile devices
fails. To avoid problems, only define capabilities and link libraries to a project
if you really need them.
For more information about capabilities and how you can check which ones you
need, see
\l{http://developer.symbian.org/wiki/index.php/Capabilities_(Symbian_Signed)}{Capabilities (Symbian Signed)}
and
\l{http://doc.qt.nokia.com/4.7-snapshot/platform-notes-symbian.html#required-capabilities}{Required Capabilities for Qt Applications}.
For more information on how to define capabilities for a project, see
\l{http://doc.qt.nokia.com/4.7-snapshot/qmake-platform-notes.html#capabilities}{Capabilities}.
\section3 Application UID
A UID is a globally unique identifier that is used to
uniquely identify, for example, an object or file type. In Symbian development,
objects are identified by compound identifiers that are constructed from three
UIDs, namely UID1, UID2, and UID3. UID1 and UID2 specify the category of an
object, whereas UID3 identifies a particular object, such as an application.
When you create a \gui {Mobile Qt Application}, Qt Creator adds a UID3 suitable for
development and debugging automatically to the application .pro file. However, to
distribute your application and get it Symbian signed, you must apply for a UID
from Symbian, who manages the allocation of UIDs. You can request UIDs either one
at a time or as preallocated blocks on the \l{https://www.symbiansigned.com/app/page}{Symbian Signed}
web site.
Replace the testing UID with the distribution UID in the .pro file before you
build the final installation package. For more information, see
\l{http://doc.qt.nokia.com/4.7-snapshot/qmake-platform-notes.html#unique-identifiers}{Unique Identifiers}.

Leena Miettinen
committed
\section2 Building and Running for Symbian Emulator
Select
the \gui{Symbian Emulator} target as the active one, and build and run your
project.

Leena Miettinen
committed
\section2 Troubleshooting
If you cannot build the application, check if:
\list
\o You selected the Symbian Device target for building the application.
\o The settings for the Qt version you use to build your project are
correct. The path to the Symbian SDK must point to the Symbian SDK
installation directory. Select \gui Tools > \gui Options...
> \gui Debugger > \gui{Symbian TRK} and check if it points to the
debugger toolchain.
\endlist
If you cannot run the application on a device, check if:
\list
\o The device is connected through the USB cable in \e{PC Suite} mode.
\o \gui{App TRK} is running on the device, using the USB connection,
with the status \e connected.
\o The device is detected and selected in the run configuration
details.
\endlist
If you cannot run the application in the emulator, check if:
\list
\o You selected the \gui{Symbian Emulator} target for your application.

Leena Miettinen
committed
\o If you cannot select \gui {Symbian Emulator} as target, check that
Carbide.c++ is installed correctly and that the path to the Carbide.c++
installation directory is specified in the \gui{Carbide directory} field
in the build settings.
\o If the emulator process cannot be started, try closing Qt Creator and
starting the application directly from your file manager. Having
done this, Qt Creator should be able to run your projects in the
emulator.

Leena Miettinen
committed

Leena Miettinen
committed
\note Qt Creator does not create release configurations for the
\gui {Symbian Emulator} target, because Symbian Emulator supports only debug
builds.
If this does not help to solve your problem, search the qt-creator@trolltech.com
mailing list archives or provide feedback to us via the methods described on the
\l{http://qt.gitorious.org/qt-creator/pages/Home}{Qt Creator Development Wiki}.

Leena Miettinen
committed
2364
2365
2366
2367
2368
2369
2370
2371
2372
2373
2374
2375
2376
2377
2378
2379
2380
2381
2382
2383
2384
2385
2386
2387
2388
2389
2390
2391
2392
2393
2394
2395
2396
2397
2398
2399
2400
2401
2402
2403
2404
2405
2406
2407
\section1 Building with Remote Compiler
The \gui {Remote Compiler} target is an interface to a compilation service at
Forum Nokia. It provides a simple, standardized environment for building Qt
applications and creating installation packages for Symbian and Maemo devices
when you do not have the necessary tool chains and SDKs installed or they are
not supported on the development PC. You can choose from a set of supported
devices, such as S60 3rd Edition or S60 5th Edition devices.
\note Remote Compiler is an experimental component that you must install
separately from the package that is included in the Nokia Qt SDK.
\list 1
\o In the Nokia Qt SDK installation directory, double-click
SDKMaintenanceTool.exe to install \gui {Experimental APIs}.
\o In Qt Creator, choose \gui {Tools > Options > Projects > Remote Compiler}
to log on to Forum Nokia.
\image remotecompiler-fn-logon.png "Remote Compiler options"
\o Choose \gui {Projects}.
\o Click
\inlineimage qtcreator-qt4-addbutton.png "Add Target button"
and select \gui {Remote Compiler} to add Remote Compiler as a target.
\o Click \gui Add to add mobile device platforms as build configurations.
\o Click the \gui {Target Selector} and select a build configuration.
\o Choose \gui {Build > Build All}.
\endlist
The installation package is generated in the \gui {Build directory} on
the development PC.
For more information about Remote Compiler, choose \gui {Help > Contents >
Remote Compiler}. The document is added during the installation of experimental
APIs.

Leena Miettinen
committed
*/
/*!
\contentspage index.html
\previouspage creator-building-targets.html
\page creator-build-settings.html
\nextpage creator-run-settings.html
\title Specifying Build Settings
You specify build settings in the \gui Projects mode.

Leena Miettinen
committed
\image qtcreator-projectpane.png
To add a new build configuration, click \gui Add and select the type of
configuration you would like to add. You can add as many build
configurations as you need.
To delete the build configuration currently selected, click \gui Remove.

Leena Miettinen
committed
\section1 Editing Build Configurations
To edit a build configuration:
\list 1
\o Select the build configuration you want to edit in
\gui{Edit Build Configuration}.
\o In section \gui General, you can specify:
\o The \l{glossary-project-qt}{Qt version} you want to use to
build your project. For more information, see
\l{Selecting the Qt version}.
\o The tool chain required to build the project.

Leena Miettinen
committed
\o By default, projects are built in a separate directory
from the source directory, as \l{glossary-shadow-build}{shadow builds}.
This keeps the files generated for each target platform separate.
\note Shadow building is not supported by the Symbian build system.
Also, shadow building on Windows is not supported for Maemo.
If you only build for one target platform, you can deselect
the \gui{Shadow Build} checkbox.
\endlist

Leena Miettinen
committed
\section1 Build Steps
The build system of Qt Creator is built on qmake and make. In
\gui{Build Steps} you can change the settings for qmake and make. Qt
Creator runs the make command using the Qt version defined for the current
build configuration.

Leena Miettinen
committed
\image qtcreator-build-steps.png "Build steps"
\section1 Clean Steps
You can use the cleaning process to remove intermediate files. This process
might help you to fix obscure issues during the process of building a
project.

Leena Miettinen
committed
\image qtcreator-clean-steps.png "Clean steps"
You can define the cleaning steps for your builds in the \gui{Clean Steps}:
\list
\o To add a clean step using make or a custom process, click
\gui{Add clean step} and select the type of step you want to add.
By default, custom steps are disabled. Activate custom steps by

Leena Miettinen
committed
checking the \gui{Enable custom process step} check-box.
\o To remove a clean step, click \gui{Remove Item}.
\o To change the order of steps, click
\inlineimage qtcreator-movestep.png
.
\endlist

Leena Miettinen
committed
\section1 Build Environment
You can specify the environment you want to use for building in the
\bold{Build Environment} section. By default, the environment in which Qt
Creator was started is used and modified to include the Qt version.
Depending on the selected Qt version, Qt Creator automatically sets the
necessary environment variables. You can edit existing environment
variables or add, reset and unset new variables based on your project
requirements.

Leena Miettinen
committed
*/
/*!
\contentspage index.html
\previouspage creator-build-settings.html
\page creator-run-settings.html
\nextpage creator-editor-settings.html
\title Specifying Run Settings
Qt Creator automatically creates run configurations for your project.

Leena Miettinen
committed
To view and modify the settings, select \gui {Projects > Run}.

Leena Miettinen
committed

Leena Miettinen
committed
The settings to specify depend on the type of the project: qmake project
or Qt Quick project.

Leena Miettinen
committed
Click \gui Add to add run settings for a project and \gui Remove to remove
the current settings.

Leena Miettinen
committed
\section1 Specifying Run Settings for qmake Projects
The run configurations for qmake projects derive their executable from the parsed .pro
files.
\section2 Specifying Run Settings for Desktop Targets
You can specify command line arguments to be passed to the executable
and the working directory to use. The working directory defaults to
the directory of the build result.
For console applications, check the \gui{Run in Terminal} check box.
If you need to run with special environment variables set up, you
also do it in the run configuration settings.
2529
2530
2531
2532
2533
2534
2535
2536
2537
2538
2539
2540
2541
2542
2543
2544
2545
2546
2547
2548
2549
2550
2551
2552
2553
2554
2555
2556
2557
2558
2559
2560
2561
2562
2563
2564
2565
2566
You can also create custom executable run configurations where you
can set the executable to be run. For more information, see
\l{Specifying a Custom Executable to Run}.
\section2 Specifying Run Settings for Symbian Devices
Qt Creator automatically detects Symbian devices that are connected to
the development PC with an USB cable.
If only one device is detected, the application is deployed
and run on it. If multiple devices are connected to the PC,
make sure that the correct device is selected in the
\gui {Symbian Device} run settings for your project.
You can also pass command line arguments to your application on the device.
Press the \gui{Device info button} to get more information about the selected
device, such as the CPU type and the running TRK version.
\image qtcreator-symbian-run-settings.png "Run settings for Symbian devices"
\section2 Specifying Run Settings for Maemo Devices
To run an application on a Maemo device, create and select
a device configuration in the Maemo run settings for your project.
You can also pass command line arguments to your application.
\image qtcreator-screenshot-run-settings.png "Run settings for Maemo devices"
\section1 Specifying a Custom Executable to Run
If you use cmake or the generic project type in Qt Creator, or want
to run a custom desktop executable, create a \gui {Custom Executable}
run configuration for your project.
Specify the executable to run, command line arguments, working directory,
and environment variables to use.
\image qmldesigner-run-custom-exe.png "Run settings for custom executables"

Leena Miettinen
committed
\section1 Specifying Run Settings for Qt Quick Projects

Leena Miettinen
committed
Select run settings in the \gui {Run configuration} field. The settings
are specified automatically and, you mostly need to change them if you
develop applications that use both C++ and QML:

Leena Miettinen
committed
\list

Leena Miettinen
committed
\o \gui {QML Viewer} is the path to the \QQV executable.
Qt Creator ships with a specific version of \QQV and imported
modules, which is used by default. If you develop applications
that use both C++ and QML, you must select the \QQV version
shipped with your Qt version here.

Leena Miettinen
committed

Leena Miettinen
committed
\o \gui {QML Viewer arguments} sets arguments for running \QQV.

Leena Miettinen
committed
The \c{-I <directory>} argument searches for C++ or QML plugins from
the project folder. For a list of available arguments, enter \c {qml --help}
on the command line.

Leena Miettinen
committed
\o \gui {Main QML file} is the Qt Quick project file.

Leena Miettinen
committed

Leena Miettinen
committed
\o \gui {Debugging address} is the IP address to access \QQV.

Leena Miettinen
committed

Leena Miettinen
committed
\o \gui {Debugging port} is the port to access \QQV. You can use any

Leena Miettinen
committed
free port in the registered port range.
\endlist
\image qmldesigner-run-settings.png "Run settings for Qt Quick projects"
*/

Kavindra Devi Palaraja
committed

Leena Miettinen
committed
/*!
\contentspage index.html
\previouspage creator-run-settings.html
\page creator-editor-settings.html
\nextpage creator-build-dependencies.html
\title Specifying Editor Settings
To define the default file encoding, select the desired encoding in \gui Projects >
\gui{Editor Settings}. By default, the Qt Creator uses the file encoding
used by your system.

Leena Miettinen
committed
\image qtcreator-editor-settings.png "Editor Settings view"
*/

Leena Miettinen
committed
/*!
\contentspage index.html
\previouspage creator-editor-settings.html
\page creator-build-dependencies.html

Leena Miettinen
committed
\title Specifying Dependencies
If you have multiple projects loaded in your session, you can define the
dependencies between them. Inter-project dependencies affect the build
order of your projects.
\note Inter-project dependencies are unrelated inside a qmake

Leena Miettinen
committed
\image qtcreator-build-dependencies.png "Dependencies view"

Leena Miettinen
committed
To define the dependencies between projects:
\list 1

Leena Miettinen
committed
\o In \gui Projects, select a project.
\o Click \gui Dependencies.
\o Select projects as dependencies.

Kavindra Devi Palaraja
committed

Leena Miettinen
committed
\page creator-getting-started.html

Leena Miettinen
committed
\nextpage creator-build-example-application.html

Leena Miettinen
committed
\title Getting Started

Leena Miettinen
committed
This section contains examples that illustrate how to use Qt Creator
to create, build, and run simple

Leena Miettinen
committed
applications:

Leena Miettinen
committed
\list

Leena Miettinen
committed
\o \l{Building and Running an Example Application}

Leena Miettinen
committed
\o \l{Creating a Qt C++ Application}

Leena Miettinen
committed
\o \l{Creating a Mobile Application with Nokia Qt SDK}

Leena Miettinen
committed
\o \l{Creating a Qt Quick Application}

Leena Miettinen
committed
\endlist
*/
/*!
\contentspage index.html
\previouspage creator-writing-program.html

Leena Miettinen
committed
\page creator-mobile-example.html
\nextpage creator-qml-application.html

Leena Miettinen
committed
\title Creating a Mobile Application with Nokia Qt SDK

Leena Miettinen
committed

Leena Miettinen
committed
\note To complete this tutorial, you must install Nokia Qt SDK.
The installation program installs and configures the necessary tool chains
for mobile application development.

Leena Miettinen
committed
2677
2678
2679
2680
2681
2682
2683
2684
2685
2686
2687
2688
2689
2690
2691
2692
2693
2694
2695
2696
2697
2698
2699
2700
2701
2702
2703
2704
2705
2706
2707
2708
2709
2710
2711
2712
2713
2714
2715
2716
2717
2718
2719
2720
2721
2722
2723
2724
2725
2726
2727
2728
2729
2730
2731
2732
2733
2734
2735
2736
2737
2738
2739
2740
2741
2742
2743
2744
2745
2746
2747
2748
2749
2750
2751
2752
2753
2754
2755
2756
2757
2758
2759
2760
2761
2762
2763
2764
2765
2766
2767
2768
2769
2770
2771
2772
2773
2774
2775
2776
2777
2778
2779
2780
2781
2782
2783
2784
2785
2786
2787
2788
2789
2790
2791
2792
2793
2794
2795
2796
2797
2798
2799
2800
2801
2802
2803
2804
2805
2806
2807
This tutorial describes how to use Qt Creator to create a small Qt
application, Battery Indicator, that uses the System Information
Mobility API to fetch battery information from the device.
\image qtcreator-batteryindicator-screenshot.png
\section1 Creating the Battery Indicator Project
\note Create the project with the \gui{Help} mode active so that you can follow
these instructions while you work.
\list 1
\o Select \gui{File > New File or Project > Qt Application Project > Mobile Qt
Application > Choose}.
\image qtcreator-new-mobile-project.png "New File or Project dialog"
The \gui{Introduction and Project Location} dialog opens.
\image qtcreator-mobile-intro-and-location.png "Introduction and Project Location dialog"
\o In the \gui{Name} field, type \bold {BatteryIndicator}.
\o In the \gui {Create in} field, enter the path for the project files. For example,
\c {C:\Qt\examples}, and then click \gui{Next}.
The \gui{Select Required Qt Versions} dialog opens.
\image qtcreator-mobile-project-qt-versions.png "Select Required Qt Versions dialog"
\o Select \gui Maemo, \gui {Qt Simulator}, and \gui {Symbian Device} targets,
and click \gui{Next}.
\note Targets are listed if you installed the appropriate development
environment, for example, as part of the Nokia Qt SDK.
The \gui{Class Information} dialog opens.
\image qtcreator-mobile-class-info.png "Class Information dialog"
\o In the \gui{Class Name} field, type \bold {BatteryIndicator} as the class name.
\o In the \gui{Base Class} list, select \bold {QDialog} as the base class type.
\note The \gui{Header File}, \gui{Source File} and \gui{Form File} fields are
automatically updated to match the name of the class.
\o Click \gui{Next}.
The \gui{Project Management} dialog opens.
\image qtcreator-mobile-project-summary.png "Project Management dialog"
\o Review the project settings, and click \gui{Finish} to create the project.
\endlist
The BatteryIndicator project now contains the following files:
\list
\o batteryindicator.h
\o batteryindicator.cpp
\o main.cpp
\o batteryindicator.ui
\o BatteryIndicator.pro
\endlist
\image qtcreator-mobile-project-contents.png "Project contents"
The files come with the necessary boiler plate code that you must
modify, as described in the following sections. You do not need
to change the main.cpp file.
\section1 Declaring the Qt Mobility API
The \gui New wizard automatically adds information to the .pro file
that you need when you use the Qt Mobility APIs or develop applications
for Symbian devices. You must modify the information to declare the
Qt Mobility APIs that you use.
This example uses the System Info API, so you must declare it, as
illustrated by the following code snippet:
\code
CONFIG += mobility
MOBILITY = systeminfo
\endcode
Each Mobility API has its corresponding value that you have to add
as a value of MOBILITY to use the API. For a list of the APIs and the
corresponding values that you can assign to MOBILITY, see the
\l {http://doc.qt.nokia.com/qtmobility-1.0/quickstart.html}{Quickstart Example}.
The following code snippet shows information that is needed for
applications developed for Symbian device. Qt Creator generated
the UID for testing the application on a device. You only need
to change the UID and capabilities if you deliver the application
for public use and need to have it Symbian Signed.
\code
symbian {
TARGET.UID3 = 0xecbd72d7
# TARGET.CAPABILITY +=
TARGET.EPOCSTACKSIZE = 0x14000
TARGET.EPOCHEAPSIZE = 0x020000 0x800000
}
\endcode
\section1 Designing the User Interface
\list 1
\o In the \gui{Editor} mode, double-click the batteryindicator.ui
file in the \gui{Projects} view to launch the integrated \QD.
\o Drag and drop a \gui{Progress Bar} (\l{http://doc.qt.nokia.com/4.7-snapshot/qprogressbar.html}{QProgressBar})
widget to the form.
\image qtcreator-mobile-project-widgets.png "Adding widgets to the UI"
\o In the \gui Properties pane, change the \gui objectName to
\bold batteryLevelBar.
\o Right-click the \gui BatteryIndicator object and select
\gui {Lay Out > Lay Out Horizontally} to ensure that the battery
indicator widget size is adjusted correctly on Maemo devices.
To adjust widget size correctly on Qt Simulator, remove the condition
from the main.cpp file (displayed in the following code snippet) and just
leave the \c {w.showMaximized();} line:
\snippet examples/batteryindicator/main.cpp 0

Leena Miettinen
committed
2819
2820
2821
2822
2823
2824
2825
2826
2827
2828
2829
2830
2831
2832
2833
2834
2835
2836
2837
2838
2839
2840
2841
2842
2843
2844
2845
2846
2847
2848
2849
2850
2851
2852
2853
2854
2855
2856
2857
2858
2859
2860
2861
2862
2863
2864
2865
2866
2867
2868
2869
2870
2871
2872
2873
2874
2875
2876
2877
2878
2879
2880
2881
2882
2883
2884
2885
2886
2887
2888
\endlist
\section1 Completing the Header File
The batteryindicator.h file contains some of the necessary #includes, a
constructor, a destructor, and the \c{Ui} object. You must include
the System Info header file, add a shortcut to the mobility name
space, and add a private function to update the battery level value in
the indicator when the battery power level changes.
\list 1
\o In the \gui{Projects} view, double-click the \c{batteryindicator.h} file
to open it for editing.
\o Include the System Info header file, as illustrated by the following
code snippet:
\snippet examples/batteryindicator/batteryindicator.h 1
\o Add a shortcut to the mobility name space, as illustrated by the
following code snippet:
\snippet examples/batteryindicator/batteryindicator.h 2
\o Declare a private function in the \c{private} section, after the
\c{Ui::BatteryIndicator} function, as illustrated by the following code
snippet:
\snippet examples/batteryindicator/batteryindicator.h 3
\endlist
\section1 Completing the Source File
Now that the header file is complete, move on to the source file,
batteryindicator.cpp.
\list 1
\o In the \gui{Projects} view, double-click the batteryindicator.cpp file
to open it for editing.
\o Create a QSystemDeviceInfo object and set its value. Then connect the signal
that indicates that battery level changed to the \c setValue
slot of the progress bar. This is illustrated by the following code snippet:
\snippet examples/batteryindicator/batteryindicator.cpp 1
\o Use the constructor to set initial values and make sure that the
created object is in a defined state, as illustrated by the following
code snippet:
\snippet examples/batteryindicator/batteryindicator.cpp 2
\endlist
\section1 Compiling and Running Your Program
Now that you have all the necessary code, select \gui {Qt Simulator}
as the target and click the
\inlineimage qtcreator-run.png
button to build your program and run it in the Qt Simulator.
In Qt Simulator, run the runOutOfBattery.qs example script
to see the value change in the Battery Indicator application.
Select \gui {Scripting > examples > runOutOfBattery.qs > Run}.
\image qtcreator-mobile-simulated.png "Mobile example in Qt Simulator"

Leena Miettinen
committed
2889
2890
2891
2892
2893
2894
2895
2896
2897
2898
2899
2900
2901
2902
2903
2904
2905
2906
2907
2908
2909
2910
2911
2912
2913
2914
2915
2916
\section1 Testing on a Symbian Device
You also need to test the application on real devices. Before you can
start testing on Symbian devices, you must connect them to the development
PC by using an USB cable and install the necessary software on them.
\list 1
\o Install Qt 4.6.2 libraries, the Qt mobile libraries, and the TRK
debugging application on the device. For more information,
see \l{Setting Up Development Environment for Symbian}.
\o Start TRK on the device.
\o Click the \gui {Target Selector} and select \gui {Symbian Device}.
\o Click \gui Run to build the application for the Symbian device.
\endlist
\section1 Testing on the Maemo Emulator
The Maemo emulator emulates the Nokia N900 device environment. You can test
applications in conditions practically identical to running the application
on a Nokia N900 device with the software update release 1.2 (V10.2010.19-1).
For more information, see \l{Using the Maemo Emulator}.

Leena Miettinen
committed
2917
2918
2919
2920
2921
2922
2923
2924
2925
2926
2927
2928
2929
2930
2931
2932
2933
2934
2935
2936
2937
2938
2939
2940
2941
2942
2943
2944
2945
2946
2947
2948
2949
2950
2951
*/
/*!
\contentspage index.html
\previouspage creator-getting-started.html
\page creator-build-example-application.html
\nextpage creator-writing-program.html
\title Building and Running an Example Application
You can test that your installation is successful by opening an existing
example application project.
\list 1
\o On the \gui Welcome page, select \gui {Choose an example... >
Animation Framework > Animated Tiles}.
\image qtcreator-gs-build-example-open.png "Selecting an example"
\o Select targets for the project. Select at least Qt Simulator
and one of the mobile targets, Maemo or Symbian Device, depending on
the device you develop for.
\image qtcreator-gs-build-example-targets.png "Selecting targets"
\note You can add targets later in the \gui Projects mode.
\o To test the application in Qt Simulator, click the \gui {Target
Selector} and select \gui {Qt Simulator}.
\image {qtcreator-gs-build-example-select-qs.png} "Selecting Qt Simulator as target"
\o Click
\inlineimage{qtcreator-run.png}
to build the application and run it in Qt Simulator.

Leena Miettinen
committed
\o To see the compilation progress, press \key{Alt+4} to open the
\gui Compile Output pane.
The \gui Build progress bar on the toolbar turns green when the project

Leena Miettinen
committed
2958
2959
2960
2961
2962
2963
2964
2965
2966
2967
2968
2969
2970
2971
2972
2973
2974
2975
2976
2977
2978
2979
2980
2981
2982
2983
is successfully built. The application opens in Qt Simulator.
\image {qt-simulator.png} "Qt Simulator"
\o Change the settings in the
\gui View pane, for example, to toggle the orientation by clicking
\gui {Rotate Device}, or choose from the various Symbian and Maemo
configurations by clicking \gui {Device}. You can also simulate various
mobile functions and create your own scripts.
\o To test the application on a Symbian device install Qt 4.6.2
and the TRK debugging application on the device. For more information,
see \l{Setting Up Development Environment for Symbian}.
\o Click the \gui {Target Selector} and select \gui {Symbian Device}.
\o Click \gui Run to build the application for the Symbian device.
\endlist
*/
/*!
\contentspage index.html
\previouspage creator-mobile-example.html

Leena Miettinen
committed
\page creator-qml-application.html
\nextpage creator-project-managing.html

Leena Miettinen
committed
\title Creating a Qt Quick Application

Leena Miettinen
committed

Leena Miettinen
committed
\note This tutorial assumes that you are familiar with the \l {http://doc.qt.nokia.com/4.7-snapshot/declarativeui.html}

Leena Miettinen
committed
{QML declarative language}.

Leena Miettinen
committed
This tutorial describes how to use Qt Creator to create a small

Leena Miettinen
committed
Qt Quick application, Hello World.

Leena Miettinen
committed
\image qmldesigner-helloworld-edited.png "Hello World"

Leena Miettinen
committed
\section1 Creating the Hello World Project
\list 1