【发布时间】:2015-03-16 11:08:36
【问题描述】:
所以,在我的一生中,我无法让我的对象连接到会话总线。所以,我试图将“my_obj”的“唤醒”连接到 dBus 信号“profileChanged”。但是,即使我确定(通过 qbusviewer)正在发出这个信号,“唤醒”也不会运行。这是我的代码的 sn-p:
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 显示“profileChanged”的格式为“void (QString)”,我没有收到任何错误或警告。这是该特定信号的 qdbus 输出:
signal void org.kde.Solid.PowerManagement.profileChanged(QString)
所以,我认为这会奏效。我确定我遗漏了一些隐藏在某些文档中的微小细节。有人知道我哪里出错了吗?
【问题讨论】: