Help: Creating a plasma 5 widget/plasmoid using QML and C++

Kevin Krammer krammer at kde.org
Sat Jul 2 10:16:42 UTC 2016


Hi Aditya,

On Friday, 2016-07-01, 23:00:27, Aditya Mehra wrote:
> Hi, I am currently trying to create a plasma 5 widget/plasmoid for
> interaction with a python application using Dbus. I am using Qml/C++ for
> building the plasmoid. I am trying to use K Develop 5 to build the widget
> but am facing many errors in the process.
> 
> The plasmoid sends and receives string values to the python application
> using QT DBus. The plasmoid builds without error inside KDevelop 5 but the
> dbus adaptor is not being initialized and neither are my other classes
> within the main function of the plasmoid. Only the QML file is displayed
> with no connection to my main function when added to the desktop or tested
> with execute in KDevelop 5.

A Plasma Applet is a plugin, which gets loaded by the Plasma host application, 
e.g. Plasma Shell.

As a plugin it doesn't have a "main" function like a program would have, i.e. 
even if your code has a main() function somewhere it won't be executed since 
the plugin is not run like an application would.

The plugin loader will use some meta data provided by the plugin to decide 
which class to instantiate when it loads the plugin.

You'll need to put your initialization code into that class.

I am not an expert on Plasma plugins but from the description of the behavior 
you are seeing my guess would be that the host application thinks you plugin 
is loaded through your main QML file.
Maybe it will try to instantiate your applet class if you remove the QML hints 
from your .desktop file.

Cheers,
Kevin
-- 
Kevin Krammer, KDE developer, xdg-utils developer
KDE user support, developer mentoring
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: This is a digitally signed message part.
URL: <http://mail.kde.org/pipermail/plasma-devel/attachments/20160702/5f6356a2/attachment.sig>


More information about the Plasma-devel mailing list