Results 1 to 7 of 7

Thread: How do i connect to QDbus signal in QTDbus ?

  1. #1
    Join Date
    Dec 2010
    Posts
    14
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default 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 .
    Last edited by noa l; 16th December 2010 at 16:12.

  2. #2
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: How do i connect to QDbus signal in QTDbus ?

    If what you posted the only connect() statement in your dialog.cpp?
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  3. #3
    Join Date
    Dec 2010
    Posts
    14
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default 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

  4. #4
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: How do i connect to QDbus signal in QTDbus ?

    Please provide a minimal compilable example reproducing the problem.
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  5. #5
    Join Date
    Dec 2010
    Posts
    14
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default 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:nclick()
    {
    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);
    }

  6. #6
    Join Date
    Dec 2010
    Posts
    14
    Qt products
    Qt4
    Platforms
    Unix/X11

    Question 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:ialog *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 ?

  7. #7
    Join Date
    Dec 2010
    Posts
    14
    Qt products
    Qt4
    Platforms
    Unix/X11

    Lightbulb 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)));

Similar Threads

  1. Connect signal/signal in Qt Designer
    By jlemaitre in forum Newbie
    Replies: 1
    Last Post: 22nd September 2010, 15:53
  2. qdbus connect return always FALSE
    By ciberkids in forum Qt Programming
    Replies: 4
    Last Post: 17th September 2009, 14:17
  3. qdbus signal
    By khcbabu in forum Qt Programming
    Replies: 1
    Last Post: 18th January 2009, 13:17
  4. QObject::connect: No such signal
    By caseyong in forum Qt Programming
    Replies: 5
    Last Post: 19th February 2008, 07:23

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.