Re: How do i connect to QDbus signal in QTDbus ?
Hi ,
(basic info : I'm using QT4.5(.2?), on gnome machine)
I need to connect to a DBus signal and will appreciate your help as I fail to do so.
I actually have two questions regarding the code below as I want to register to "StatusChanged" signal under "/org/gnome/SessionManager/Presence" (I do have it on my machine and i can register to it through the qdbusviewer):
Q-a: Do i send the correct arguments to the QDBusInterface constructor ?
Q-b: When running this code and getting to the connect line I get the following message:
Object::connect: No such signal org::gnome::SessionManager::Presence::StatusChange d(int) in dialog.cpp
So how am i supposed to register to the signal?
My code is:
QDBusConnection bus = QDBusConnection ::sessionBus();
QDBusInterface *dbus_iface = new QDBusInterface("org.gnome.SessionManager","/Presence",
"org.gnome.SessionManager.Presence", bus);
connect(dbus_iface, SIGNAL(StatusChanged(int)), this, SLOT(MySlot(int));
Added after 11 minutes:
more info :
I changed second argument of constructor to be "/org/gnome/SessionManager/Presence". I'm getting the following message:
Invalid D-Bus member name 'stats-tezt' found in interface 'org.gnome.SessionManager.Presence' while parsing introspection
So I guess it is correct because indeed theere is such property,
but I'm still getting the "no suych signal.." error .
Re: How do i connect to QDbus signal in QTDbus ?
If what you posted the only connect() statement in your dialog.cpp?
Re: How do i connect to QDbus signal in QTDbus ?
Thanks
I'm sorry but i'mnot sure i understood your question. The code i wrote here is the only code of the application. It is executed when a button is clicked.
I'll try to explain again - just to make sure it is clear :-)
I want to be notified by signal "StatusChanged" of "/org/gnome/SessionManager/Presence
When this signal is "signaled' i want "MySlot" slot Dialog::method to be called.
How do i do it ? (The code is within a Dialog method)
Apparently I did something wrong as I get an error message saying that
"Object::connect: No such signal org::gnome::SessionManager::Presence::StatusChange d(int) in dialog.cpp
"
I did not define any "StatusChanged" - as it is supposed to be a signal of the remove interface of DBUS.
Can anyone add here a working example ?
Maybe the (int) is wrong?
Thanks all in advance
Noa
Re: How do i connect to QDbus signal in QTDbus ?
Please provide a minimal compilable example reproducing the problem.
Re: How do i connect to QDbus signal in QTDbus ?
unfortunately i cannot get to the development machine at the moment - but i just created a basic QT application using the QTCreator - added a button , and on click i activated the following code:
void Dialog::onclick()
{
QDBusConnection bus = QDBusConnection ::sessionBus();
QDBusInterface *dbus_iface = new QDBusInterface("org.gnome.SessionManager","/org/gnome/SessionManager/Presence", "org.gnome.SessionManager.Presence", bus);
connect(dbus_iface, SIGNAL(StatusChanged(int)), this, SLOT(MySlot(int));
}
void Dialog::MySlot(int status)
{
printf("status is %d\n", status);
}
Re: How do i connect to QDbus signal in QTDbus ?
But maybe this question will help to figure it our:
My "Dialog" is defined like this:
class Dialog : public QDialog
{
Q_OBJECT
public:
Dialog(QWidget *parent = 0);
~Dialog();
private:
Ui::Dialog *ui;
private slots:
void on_pushButton_clicked();
void MySlot(int status);
};
and the connect code is found in the on_pushButton_clicked() method.
But - don't i need the instance calling the "connect" to derive from some QTDbus class ?
Re: How do i connect to QDbus signal in QTDbus ?
So
I will answer my own question , for the benefit of my followers ...
The connect line should be as described here:
QDBusConnection::sessionBus().connect("org.gnome.S essionManager", "/org/gnome/SessionManager/Presence", "org.gnome.SessionManager.Presence" ,"StatusChanged", this, SLOT(MySlot(uint)));