我正在尝试将一些c++/qt代码转换为Python/qt
在c++中使用QDBusInterface:
auto qi = make_unique<QDBusInterface>("org.freedesktop.UPower", /org/freedesktop/UPower, "org.freedesktop.UPower", QDBusConnection::systemBus());
此时,我已经可以从其属性中读取值:
auto prop = qi.property("OnBattery");
不幸的是,在Python中执行相同操作时,它不能以这种方式工作:
qi = QDBusInterface(serviceObject, path, interface, QDBusConnection.systemBus())
qi.isValid()返回True,但正在读取属性:
onBattery = qi.property("OnBattery")
返回无
也调用枚举设备的方法,既在C++和Python
上工作有没有办法让它发挥作用
这里的问题是缺乏好的例子:
我自己找到了间接的解决办法
它不再使用
QDBusInterface
,转而使用Python的dbus
,可以像这样使用哪个API link相关问题 更多 >
编程相关推荐