我正在 Ubuntu 上使用 QDBus 进行 C++ 编程,我得到了以下代码片段:
this->m_cRemoteInterface = new QDBusInterface("org.my.service", "/data", "org.freedesktop.DBus.Properties.Get");
QDBusReply<uint64_t> cResult = m_cRemoteInterface->call("property1");
代码抛出以下错误:
org.freedesktop.DBus.Error.UnknownMethod: Method "property1" with signature "" on interface "org.freedesktop.DBus.Properties.Get" doesn't exist
但是当我在 shell 中发出以下命令时,它会返回正确的值:
dbus org.my.service /data org.freedesktop.DBus.Properties.Get " " property1
我可能做错了什么?
提前致谢,艾米
最佳答案
经过一下午的尝试和错误:
我声明了
org.freedesktop.DBus.Properties.Get
作为接口(interface),这是不对的。
我只需要使用
org.freedesktop.DBus.Properties
作为界面,然后
call("Get", " ", "property1");
愿这对某人有帮助。 :)。
关于linux - QDBus问题: getting org. freedesktop.DBus.Error.UnknownMethod,但方法存在,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3456581/