< Development‎ | Tutorials‎ | Plasma4
Revision as of 10:43, 11 March 2011 by Frederik.gladhorn (Talk | contribs)

(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search



Writing a plasma applet in QML is very easy, in fact, with KDE 4.6 and Qt 4.7 it just works.

Package Structure

You create a .desktop file and the .qml file. They have to be in the usual plasma package structure.

plasmoid-qml/metadata.desktop plasmoid-qml/contents/qml/main.qml


[Desktop Entry] Name=Hello QML Comment=A hello world widget in QML Icon=chronometer

X-Plasma-API=declarativeappletscript X-Plasma-MainScript=qml/main.qml X-Plasma-DefaultSize=200,100

X-KDE-PluginInfo-Author=Frederik Gladhorn X-KDE-PluginInfo-Website= X-KDE-PluginInfo-Category=Examples X-KDE-PluginInfo-Name=org.kde.hello-qml X-KDE-PluginInfo-Version=0.0

X-KDE-PluginInfo-Depends= X-KDE-PluginInfo-License=GPL X-KDE-PluginInfo-EnabledByDefault=true X-KDE-ServiceTypes=Plasma/Applet Type=Service


import Qt 4.7

Text {

   text: "Hello world!";

} <code>


You can install your plasmoid: plasmapkg --install plasmoid-qml


You can run it in plasmoidviewer as usual: plasmoidviewer plasmoid-qml


And you can run it in qmlviewer: qmlviewer -I /usr/lib/kde4/imports/ plasmoid-qml/contents/qml/main.qml

Where the -I is the path to the plasma plugin for qml. Try to look for the path of /usr/lib/kde4/imports/org/kde/plasma/graphicswidgets/ and use everything up to org of that path.

KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V.Legal