Creating a Qt Quick Application Using Qt Quick ComponentsNote: To complete this tutorial, you must install the Qt Quick Components for Symbian and the Symbian^3 tool chain as part of the Qt SDK. In addition, you must install the Qt Quick Components on the test device. This tutorial describes how to use Qt Creator to create a small Qt application, Battery Status, that uses the System Information Mobility API to fetch battery information from the device. The user interface for the application is designed using Qt Quick Components for Symbian. This enforces a platform look and feel for Symbian^3 devices. Creating the Project
Qt Creator generates the necessary files that contain boiler plate code. The wizard creates an application that uses page-based application navigation. Modify the files as described in the following sections. Declaring the Qt Mobility APITo use the Qt Mobility APIs or develop applications for Symbian devices, you must modify the .pro file 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: CONFIG += mobility MOBILITY = systeminfo 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 Quickstart Example. Adding Import StatementsThe wizard adds the import statements for Qt Quick and the Qt Quick Components for Symbian to the MainPage.qml file: import QtQuick 1.0 import com.nokia.symbian 1.0 To use the Qt Mobility APIs, you must add the import statements for the Qt Mobility APIs that you use. This example uses the System Info API, so you must import it, as illustrated by the following code snippet: import QtMobility.systeminfo 1.1 Use the values as you can assign to MOBILITY also to construct import statements. Creating the Main ViewQt Creator generates a default QML file that you can modify to create the main view of the application. It displays a progress bar and a text label that indicate the battery status.
Fetching Battery StatusTo fetch the battery status, open MainPage.qml in the code editor and add some code to it:
Compiling and Running Your ProgramNow that you have all the necessary code, select Qt Simulator as the target and click the In Qt Simulator, run the runOutOfBattery.qs example script to see the value change in the Battery Status application. Select Scripting > examples > runOutOfBattery.qs > Run Selected Script. Testing on a Symbian DeviceYou 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 a USB cable and install the necessary software on them.
X
|
Publicité
Best OfActualités les plus luesSemaine
Mois
Année
Le Qt Labs au hasard![]() QMake et au-delàLes Qt Labs sont les laboratoires des développeurs de Qt, où ils peuvent partager des impressions sur le framework, son utilisation, ce que pourrait être son futur. Lire l'article.
CommunautéRessources
Liens utilesContact
Qt dans le magazine |
Cette page est une traduction d'une page de la documentation de Qt, écrite par Nokia Corporation and/or its subsidiary(-ies). Les éventuels problèmes résultant d'une mauvaise traduction ne sont pas imputables à Nokia. | Qt qtcreator-2.3 | |
Copyright © 2012 Developpez LLC. Tous droits réservés Developpez LLC. Aucune reproduction, même partielle, ne peut être faite de ce site et de l'ensemble de son contenu : textes, documents et images sans l'autorisation expresse de Developpez LLC. Sinon, vous encourez selon la loi jusqu'à 3 ans de prison et jusqu'à 300 000 E de dommages et intérêts. Cette page est déposée à la SACD. | ||
Vous avez déniché une erreur ? Un bug ? Une redirection cassée ? Ou tout autre problème, quel qu'il soit ? Ou bien vous désirez participer à ce projet de traduction ? N'hésitez pas à nous contacter contacter par email ou par MP ! |
Copyright © 2000-2012 - www.developpez.com