大神请进!QT用QDBus与后台python写的服务器通信,列表元素如何获取
大神请进!QT用QDBus与后台python写的服务器通信,列表元素怎么获取
QT用QDBus与后台python写的服务器通信,列表元素怎么在QT中获取?
如:调用get_partition_info(“/dev/sda3”)这个函数,它的返回值是Variant类型。
返回值为
[{'PartitionFree': '83093.5507812M',
'PartitionMountpath': '/',
'PartitionName': '/dev/sda3',
'PartitionSystem': 'ext4',
'PartitionTotal': '95561.9375M',
'PartitionType': 'root fs',
'PartitionUsed': '7591.57421875M'}]
我应该怎么用QT获取这串数据。
------解决方案--------------------
python端:out_signature='aa{sv}'
Qt端:注册类型:
typedef QList<QVariantMap> mapList;
Q_DECLARE_METATYPE(mapList)
在调用call时,注册qDBusRegisterMetaType<mapList>();
QDBusReply<mapList> reply = ....call
然后按照类型解析就行了。
QT用QDBus与后台python写的服务器通信,列表元素怎么在QT中获取?
如:调用get_partition_info(“/dev/sda3”)这个函数,它的返回值是Variant类型。
返回值为
[{'PartitionFree': '83093.5507812M',
'PartitionMountpath': '/',
'PartitionName': '/dev/sda3',
'PartitionSystem': 'ext4',
'PartitionTotal': '95561.9375M',
'PartitionType': 'root fs',
'PartitionUsed': '7591.57421875M'}]
我应该怎么用QT获取这串数据。
------解决方案--------------------
python端:out_signature='aa{sv}'
Qt端:注册类型:
typedef QList<QVariantMap> mapList;
Q_DECLARE_METATYPE(mapList)
在调用call时,注册qDBusRegisterMetaType<mapList>();
QDBusReply<mapList> reply = ....call
然后按照类型解析就行了。