Viadeo Twitter Google Bookmarks ! Facebook Digg del.icio.us MySpace Yahoo MyWeb Blinklist Netvouz Reddit Simpy StumbleUpon Bookmarks Windows Live Favorites 
Logo Documentation Qt ·  Page d'accueil  ·  Toutes les classes  ·  Toutes les fonctions  ·  Vues d'ensemble  · 

Declarative Service Framework Notes Manager

This example demonstrates how to use the Notes Manager service plugin to implement a notes managing application with QML as the declarative user-interface. There is also a non-QML counterpart which demonstrates an identical application using standard Qt user-interface tools. See Service Framework Notes Manager for more details.

Explanation

The QServiceManager and QServiceInterfaceDescriptor API are provided to QML through the use of a plugin-based system. The resulting class is referred to as QDeclarativeService, which provides users with the ability of accessing services by loading the interfaces specified using the QML element 'Service'.

This example demonstrates how QML can be used to completely control the logic of the application, using a combination of declarative elements and Javascript in the QML file. To run the application refer to the README file supplied which includes instructions on how to setup and run the QML file demonstrating service framework capabilities.

There is also another service framework example that demonstrates how to use the QML library plugin browse a list of services to select for dialing usage. See Declarative Service Framework Dialer for a detailed explanation.

The section below explains how QML can be used to emulate to exact functionality of the alternate Qt/C++ example.

QML File

The very first step is to import our registered types with the following:

    import QtMobility.serviceframework 1.0

Now to obtain the default service with a specific interface name from within QML we can use the Service wrapper item as follows:

        Service {
            id: notesService
            interfaceName: "com.nokia.qt.examples.NotesManager"
        }

In most cases we will need the service to be available to all parts of the QML file, meaning the actual QObject returned from the service wrapper needs to be a global property.

        property variant notesManager: notesService.serviceObject

The interfaceName property of the Service item has READ and WRITE methods which can be used to obtain a new service instance and check if there was a valid default service.

                notesService.interfaceName = input;

                if (notesService.valid) {
                    notesManager = notesService.serviceObject;

With a valid reference which points to the service plugin class we can now invoke methods directly from the Notes Manager plugin. The example below shows how to obtain a list of notes and delete one from the notes manager database through QML.

                var list = notesManager.noteSet;
                notesManager.removeNote(list[curr-1].index);

The Notes Manager plugin also provides readable functions which return the values of a single note and can be utilized to display on the UI as follows:

            notesManager.setSearch(searchText);
            var list = notesManager.noteSet;
            size = list.length;

            if (size > 0) {
                noteLabel.text = list[curr-1].message;
                datetimeLabel.text = formatDateTime(list[curr-1].alarm);
            }

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 qtmobility-1.0
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 ou par MP !
 
 
 
 
Partenaires

Hébergement Web