PDA

View Full Version : Connecting dbus signal iwth Qt Apps



yuvaraj.addu
13th June 2011, 07:32
Hi All,

I want to connect dbus signal with my Qt Apps.

Tried with below mentioned piece of code
example::example(const QString &service, const QString &path, const char *interface,const QDBusConnection &connection,QObject *parent):QDBusAbstractInterface(service, path, interface,connection,parent)
{

bool val= this->connection().connect(service,path,QString("/myInterface),QString("PropertyChanged"),QString("QString,QDBusVariant"),this,SLOT(stateChanged(QString,QVariant)));
qDebug() << " Value is " << val;


}


Here my Dbus signal signature is



PropertyChanged(string name, variant value)



Always my slot is not at all connected

Could anybody provide here sample code.


Thanks

Yuvaraj

yuvaraj.addu
13th June 2011, 07:50
** merged! **

Hi All

Please refer this link http://www.qtcentre.org/threads/42374-Connecting-dbus-signal-iwth-Qt-Apps (http://www.qtcentre.org/threads/42374-Connecting-dbus-signal-iwth-Qt-Apps).

Already i have posted my issue in newbie section.


Thanks

Yuvaraj

ChrisW67
13th June 2011, 08:03
Deliberate cross-posting is unlikely to win you any favours.

yuvaraj.addu
13th June 2011, 09:11
Hi All,

Could anybody help me on this issue?

Thanks

Yuvaraj R

ChrisW67
13th June 2011, 10:06
You have a missing close quote in your code snippet.

Does Qt issue a warning about your connection when you run the program? Is stateChanged() declared as a slot?

yuvaraj.addu
13th June 2011, 10:23
Hi,

yes i declared stateChanged.

I suspect, problem with


bool val= this->connection().connect(service,path,QString("/myInterface),QString("PropertyChanged"),QString("QString,QDBusVariant"),this,SLOT(stateChanged(QString,QVariant)));



Thanks


Yuvaraj R

ChrisW67
13th June 2011, 11:13
You still have a missing double-quote in your code example. You didn't answer my question regarding warnings.

I don't use Dbus but a cursory reading of the docs would indicate that your third argument (interface) is not correct. It looks like a path and not a dotted DBus interface name as, for example, you see in the D-Bus Remote Controlled Car Example.

You also say that the Dbus signature is "string name, variant value" but that is not the same as the signature in your call: "Q String,QDBusVariant". I don't know if this is correct or not.

yuvaraj.addu
17th June 2011, 13:44
Hi,

I solved this issue 4 days back itself . I forgot to update here

Solution:


QDBusConnection::systemBus().connect(SERVICE,path, INTERFACE,"PropertyChanged",this,SLOT(stateChanged(QString,QDBusVariant)));


Thanks

Yuvaraj R