[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kde-panel-devel
Subject:    Re: Plasmoid plugin signal handling
From:       Sebastian =?UTF-8?Q?K=C3=BCgler?= <sebas () kde ! org>
Date:       2017-06-14 11:30:14
Message-ID: 20170614133014.3e71b9c1 () manta ! vizZzion ! net
[Download RAW message or body]

On Wed, 14 Jun 2017 10:39:04 +0200
Rastislav Marko <cdfghglz@gmail.com> wrote:

> Thank you for the hints, I made the semantics more meaningful (in
> fact I have another class named ActiivtyJumper).
> 
> On utorok, 13. júna 2017 16:49:26 CEST Sebastian Kügler wrote:
> > 
> > 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.  
> 
> I can not really find a reference to DBusObject, what should it
> represent?

Sorry, I meant "DBusInterface", that's the class name your C++ code,
which you rename to ActivityJumper in the qmlRegisterType statement.
(Might I suggest a less general, more meaningful name for
DBusInterface?)

> > > ---------- main.qml
> > > 
> > > Item {
> > > 
> > >     id: main
> > >     
> > >     ActivityJumper {
> > >     
> > >         id: activityJumper  
> > 
> > Here, it'll be found:
> > 
> > 	 		onSignalDesktopChanged: print("desktop   
> changed!")
> >   
> 
> I tried this before, but I was appearently missing a proper import
> (import org.kde.private.activityjumper 1.0) in the main.qml. Then I
> tried to use the Connections as a workaround. With the import the
> handler works from the object instance in main.qml like charm.

Yes, you need to use that import whenever you use your objects /
classes defined within the scope of that import.

Connection works as well, but it's way clearer to put the signal
handler within the object that defines it, keeps code nicely grouped
and reduces the creation of an unnecessary Connection object.

> Thanks!

Cheers,
-- 
sebas

    http://vizZzion.org   ⦿    http://www.kde.org
[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic