- class QDBusPendingCallWatcher#
The
QDBusPendingCallWatcher
class provides a convenient way for waiting for asynchronous replies. More…概述#
方法#
def
__init__()
信号#
def
finished()
注意
This documentation may contain snippets that were automatically translated from C++ to Python. We always welcome contributions to the snippet translation. If you see an issue with the translation, you can also let us know by creating a ticket on https:/bugreports.qt.io/projects/PYSIDE
详细描述#
警告
This section contains snippets that were automatically translated from C++ to Python and may contain errors.
《QDBusPendingCallWatcher》为当接收回复时提供
finished()
信号。通常使用方式如下所示:
async = iface.asyncCall("RemoteMethod", value1, value2) watcher = QDBusPendingCallWatcher(async, self) watcher.finished.connect(this, DBus_PendingCall_Interface.callFinishedSlot)
注意,由于
QDBusPendingCall
也继承自该类,因此不需要保留原始的QDBusPendingCall
对象。上述代码连接的槽函数可能如下所示:
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])#
- 参数:
call -
QDBusPendingCall
parent -
QObject
创建一个用于监视异步待解决调用
call
回复的QDBusPendingCallWatcher
对象,并将此对象的父对象设置为parent
。- finished([self=None])#
- 参数:
self -
QDBusPendingCallWatcher
当待解决调用完成并且回复可用时,发出此信号。参数
self
是对象的指针,为方便起见传递,以便槽可以访问属性并确定回复的内容。