Introduction to the Plasmoid QML Declarative API
This document provides an overview/reference of the Declarative QML API for Plasmoids. It isn't a full binding to all of Qt or KDE's libraries, but a focused set of bindings designed to make writing Plasmoids fast and easy, while remaining powerful.
The API in this documentation covers the API of the Plasma specific QML components, so only the Declarative part of the API.
To denote that this Plasmoid is a Declarative widget, ensure that in the metadata.desktop file there is this line:
What follows is a description of the Plasma declarative classes instantiable from QML.
DataSource is a receiver for a dataEngine and can be declared inside QML:
It has the following properties:
- bool valid: true when the DataSource is successfully connected to a data engine
- int interval: interval of polling of the dataengine, if 0 no polling will be executed
- string engine: the plugin name of the dataengine to load
- Array(string) connectedSources: all the sources of the dataengine we are connected to (and whose data will appear in the data property)
- Array(string) sources: all the sources available from the dataengine
- variant map data: It's the most important property, it's a map of all the data available from the dataengine: its structure will be as follows:
- each key of the map will be a source name, in connectedSources
- each value will be a variant hash, so an hash with strings as keys and any variant as value
- example: dataSource.data["Local"]["Time"] indicates the Time key of the dataengine source called "Local"
It has the following methods:
- StringList keysForSource(String source): lists all the keys corresponding to a certain source: for instance in the "time" dataengine, for the "Local" source, keys will be:
- "Timezone Continent"
- "Timezone City"
- Service serviceForSource(String source): returns a Plasma service that corresponds a given source: see the section about services for how to use it.
Top Level windows