Examples and Tutorials
The benefits of writing your Plasmoid with QML can include faster development with more sophisticated results visually and in its usability as well as much better performance when run in a QML-only Plasma shell such as Plasma Active.
On top of the ECMA Script language, QtScript provides Qt integration features. Probably the most useful one in this context is the use of signals and slots which is Qt's callback mechanism. Signals may be emitted in QtScript by calling the signal method in question, a signal can be connected to a slot by using the connect() method (and disconnected with disconnect()) and any function defined in the Plasmoid may be used as a slot. For example:
print("We got clicked!")
button = new PushButton
This will print out:
We got clicked!
on the console when the Plasmoid starts, and the "We got clicked!" again whenever the button is clicked by the user.
The object that emitted the signal that caused a slot to be called can be retrieved using the QObject sender read-only property of the global plasmoid object.
- The Global plasmoid Object
- Global Enumerations
- User Interface Elements
- Accessing Sources of Data with DataEngines and Services
- Printing To Console and Debug Output
- Asynchronous Input/Output (IO) Jobs
- Utility API and Objects