2016-01-08 32 views
1

我试图连接到从的ObjectManager使用下面的代码InterfacesAdded信号:C++的Qt的DBus没有这样的信号InterfacesAdded

UDisks::UDisks(QObject *parent) : QObject(parent), disks(UD_SERVICE, 
    UD_PATH, UD_INTERFACE_OBJECT_MANAGER, QDBusConnection::systemBus()) 
{ 
    qDBusRegisterMetaType<InterfaceList>(); 
    qDBusRegisterMetaType<ManagedObjectList>(); 

    connect(&disks, SIGNAL(InterfacesRemoved(QDBusObjectPath, QStringList)), this, SLOT(mediaRemoved(QDBusObjectPath, QStringList))); 
    connect(&disks, SIGNAL(InterfacesAdded(QDBusObjectPath, InterfaceList)), this, SLOT(mediaAdded(QDBusObjectPath,InterfaceList))); 

} 

当我运行的代码,它与下面的错误出现:

QObject::connect: No such signal org::freedesktop::DBus::ObjectManager::InterfacesAdded(QDBusObjectPath, InterfaceList) 

下面是InterfaceList typedef的:

typedef QMap<QString, QMap<QString, QVariant>> InterfaceList; 

回答

1

通过调试QtDBusVi壶我能够通过使用此代码,找到解决我的问题:

QDBusConnection connection(QDBusConnection::systemBus()); 
connection.connect(UD_SERVICE, UD_PATH, UD_INTERFACE_OBJECT_MANAGER, "InterfacesAdded", this, SLOT(mediaAdded(QDBusObjectPath,InterfaceList))); 

原来我需要创建使用QDbusConnection类,而不是使用的QObject的连接方法信号的连接。

相关问题