PySide6.QtDBus.QDBusPendingCallWatcher¶
- class QDBusPendingCallWatcher¶
QDBusPendingCallWatcher类提供了一种方便的方式来等待异步回复。更多…概要¶
方法¶
def
__init__()
信号¶
def
finished()
注意
本文档可能包含从C++自动翻译到Python的代码片段。我们始终欢迎对代码片段翻译的贡献。如果您发现翻译问题,您也可以通过在我们的https:/bugreports.qt.io/projects/PYSIDE上创建工单来告知我们。
详细描述¶
警告
本节包含从C++自动翻译到Python的代码片段,可能包含错误。
QDBusPendingCallWatcher提供了finished()信号,当回复到达时将会发出该信号。通常使用如下示例:
async = iface.asyncCall("RemoteMethod", value1, value2) watcher = QDBusPendingCallWatcher(async, self) watcher.finished.connect(this, DBus_PendingCall_Interface.callFinishedSlot)
请注意,没有必要保留原始的
QDBusPendingCall对象,因为QDBusPendingCallWatcher也继承自该类。上述代码连接的插槽可能类似于以下内容:
def callFinishedSlot(self, call): QByteArray> reply = call if reply.isError(): showError() else: text = reply.argumentAt<0>() data = reply.argumentAt<1>() showReply(text, data) call.deleteLater()
注意使用
QDBusPendingReply来验证回复中的参数类型。如果回复不包含恰好两个参数(一个字符串和一个QByteArray),isError()将返回true。另请参阅
QDBusPendingReply- __init__(call[, parent=None])¶
- Parameters:
call –
QDBusPendingCallparent –
QObject
创建一个
QDBusPendingCallWatcher对象来监视异步挂起调用call的回复,并将此对象的父级设置为parent。- finished([self=None])¶
- Parameters:
self –
QDBusPendingCallWatcher
当挂起的调用完成并且其回复可用时,会发出此信号。
self参数是指向对象本身的指针,为了方便传递,以便槽可以访问属性并确定回复的内容。