1

So, for the life of me, I can't get my object to connect to the session bus. So, I'm trying to connect "wakeup" of "my_obj" to the dBus signal "profileChanged". But, even though I'm sure (via qbusviewer) that this signal is being emitted, "wakeup" will not run. Here is a snippet of my code:

const QString service = "org.kde.Solid.PowerManagement";
const QString path = "/org/kde/Solid/PowerManagement";
const QString interface = "org.kde.Solid.PowerManagement";    

QDBusConnection bus = QDBusConnection::sessionBus();

if (!bus.isConnected()) 
{
      qDebug() << "Can't connect to the D-Bus session bus.\n";
}                

class my_wake_up_class : public QObject
{
      Q_OBJECT
public slots:
      void wakeup(QString); //Does not run!
};

my_wake_up_class my_obj;

bool conn = bus.connect(service, path, interface, "profileChanged", &my_obj, SLOT(wakeup(QString)));
if (!conn) qDebug() << "not connected";

qDBus shows that "profileChanged" has the form "void (QString)" and I'm not getting any errors nor warnings. Here is the qdbus output for that particular signal:

signal void org.kde.Solid.PowerManagement.profileChanged(QString)

So, I'd think this would work. I'm sure I'm missing some minute detail that's buried deep within some documentation. Would anybody know where I'm going wrong?

4

1 回答 1

2

所以,qtforum.org 上的好人嘲笑我的无知。显然,我需要启用 Qt 事件系统。通常这是由我没有包含的 QApplication 类完成的。一旦包括在内,一切正常。

于 2015-01-20T02:50:07.487 回答