SystemInfo QML PluginOverviewThe System Information API gives the developer a convenient way to access various sources of information on a device within the powerful QtQuick environment. Many signals that you may wish to use require that a property with a name beginning with 'monitor' be used, for example setting monitorStatusChanges to true will start status change events being emitted as signals (in the NetworkInfo element). AlignedTimerThe AlignedTimer element allows timing functions in order to synchronize a number of activities. A one-shot feature is included as well as properties for minimum and maximum timer intervals. BatteryInfoThe BatteryInfo element contains a set of functions and properties for interrogating and handling notifications of battery information. We will use the battery example, battery2.qml, to show how to use the element and the plugin. The following QML code enables a number of events and defines several handlers. BatteryInfo { id: batinfo; property int battlevel: remainingCapacityPercent; property string oldstate; monitorChargerTypeChanges: true monitorChargingStateChanges: true monitorBatteryStatusChanges: true monitorRemainingCapacityPercentChanges: true monitorRemainingCapacityChanges: true monitorRemainingChargingTimeChanges: true monitorCurrentFlowChanges: true onChargerTypeChanged: { ... In particular, when the battery level changes the handler onRemainingCapacityPercentChanged: doBatteryLevelChange(level) calls function doBatteryLevelChange(level) { leveltext.text = "Level: "+ level +"%" floorParticles.burst(level); batlevel = level; batinfo.oldstate = img.state; img.state = "levelchange" //img.state = batinfo.oldstate; getPowerState(); } which results in a change of State to levelchange being handled after the function. The levelchange state then causes a suitable animation to run and display the new level. State { name: "levelchange" ... PropertyChanges { target: bubblebounceanim from: screen.height to: screen.height - (screen.height * (batlevel / 100 )) } ... DeviceInfoIn the battery2.qml example above we saw a BatteryInfo element used to set up various signal handlers, one for battery level changes. BatteryInfo is a specialized wrapper of the same class used for DeviceInfo. DeviceInfo is an element that contains properties, signals and handlers for a variety of components of the device. So it not only caters for the battery but also manufacturer id, the thermal state, keyboard, whether the device locked and so forth. DisplayInfoThe DisplayInfo element contains properties relating to the physical display such as width and height, and also resolution information given as the width and height in dpi. Only one signal is available, orientationChanged. The meaning of the values used in some of the properties and the reported orientation can be found in the QSystemDisplayInfo documentation. GeneralInfoThis is a convenience class and is not expected to be used directly by developers. NetworkInfoThe NetworkInfo element provides properties of a network connection and session and various signals. The QML plugin example, wifi.qml, gives a simple demonstration on how to use some of these properties. Item { id: wlan ... property int mode: NetworkInfo.WlanMode; ... NetworkInfo { id: wlaninfo mode: wlan.mode; property string img : getImage(networkStatus); function getImage(newStatus) { if(newStatus == "Connected") { return "images/wlan.svg"; } return "images/wlan-noavail.svg"; } onStatusChanged : { img = getImage(newStatus) } monitorNameChanges: true; monitorSignalStrengthChanges: true monitorStatusChanges: true monitorModeChanges: true } The Item element named wlan has its declared mode property set to the wireless lan mode enum. The NetworkInfo element wlaninfo also contains the connection status, represented by a string indicating a suitable image to display. The signal handler onStatusChanged will call the function that sets the image. Finally, in the NetworkInfo element we find a series of statements that enable signals for name changes, status changes, signal strength changes and mode changes. ScreenSaverThe ScreenSaver element provides information about whether the screensaver has been delayed or inhibited and the ability to set the delayed boolean flag. QML Elements
Compatibility Notes |
Publicité
Best OfActualités les plus luesSemaine
Mois
Année
![]()
![]() Le Qt Developer Network au hasard![]() Extension de Qt WebKitLe Qt Developer Network est un réseau de développeurs Qt anglophone, où ils peuvent partager leur expérience sur le framework. 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 qtmobility-1.2 | |
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 ! |
Copyright © 2000-2012 - www.developpez.com