Plasmoid plugin signal handling

Sebastian Kügler sebas at kde.org
Tue Jun 13 14:49:26 UTC 2017


On dinsdag 13 juni 2017 16:27:47 CEST cdfghglz at gmail.com wrote:
[...]
>     qmlRegisterType<DBusInterface>(uri, 1, 0, "ActivityJumper");

Why not call this class ActivityJumper in the first place, it's generally less 
confusing to align class names with their QML names.

> ---------- ActivityJumper.qml
> 
> Item {
>     id: activityJumper
> 
>     property var activityJumperPlugin: null
>     property bool activityJumperFailedToInitialize: false
> 
>     Connections {
>        target: activityJumper
>        onSignalDesktopChanged: console.log("got the signal")
>     }

The signal isn't defined in "Item", you need to create a DBusObject object in 
your QML code, then you can add a signal handler.

[...]
> ---------- main.qml
> 
> Item {
>     id: main
> 
>     ActivityJumper {
>         id: activityJumper

Here, it'll be found:

	 		onSignalDesktopChanged: print("desktop changed!")


Be careful, duplicate ids may lead to confusion (not a problem in separate 
files, but better safe than sorry, better make it semantically correct in the 
first place.

> With this I get the error: "QML Connections: Cannot assign to non-existent
> property "onSignalDesktopChanged"".
> 
> Can you tell me what I am doin wrong or give me a hint what is the simplest
> way to catch a plugin signal in qml?
> 
> Thanks a lot in advance!

Cheers,
-- 
sebas

http://www.kde.org | http://vizZzion.org


More information about the Plasma-devel mailing list