QDBusPendingCall Class
QDBusPendingCall 类指代一个待处理异步调用。更多
头文件: | #include <QDBusPendingCall> |
CMake: | find_package(Qt6 REQUIRED COMPONENTS DBus) target_link_libraries(mytarget PRIVATE Qt6::DBus) |
qmake: | QT += dbus |
继承于 |
- 所有成员的列表,包括继承成员
- QDBusPendingCall 属于隐式共享类。
公共函数
QDBusPendingCall(const QDBusPendingCall &other) | |
~QDBusPendingCall() | |
void | swap(QDBusPendingCall &other) |
QDBusPendingCall & | operator=(const QDBusPendingCall &other) |
静态公共成员
QDBusPendingCall | fromCompletedCall(const QDBusMessage &msg) |
QDBusPendingCall | fromError(const QDBusError &error) |
详细描述
QDBusPendingCall 对象是对通过 D-Bus 发送但未等待回复的方法调用的引用。QDBusPendingCall 是一种不透明类型,可用作待回复的句柄。
在大多数程序中,QDBusPendingCall 类不会被直接使用。它可以安全地替换为基于模板的QDBusPendingReply ,以便访问回复内容或等待回复完成。
QDBusPendingCallWatcher 类允许连接一个信号,该信号将指示回复何时到达或呼叫是否超时。它还提供了QDBusPendingCallWatcher::waitForFinished() 方法,该方法将暂停程序的执行,直到回复到达。
注意: 如果创建了 QDBusPendingCall 对象的副本,那么所有信息都将在多个副本中共享。因此,QDBusPendingCall 是一个显式共享对象,不提供分离副本的方法(因为它们引用的是同一个挂起调用)。
另请参阅 QDBusPendingReply 和QDBusPendingCallWatcher 。
成员函数文档
QDBusPendingCall::QDBusPendingCall(const QDBusPendingCall &other)
创建other 待处理异步调用的副本。请注意,这两个对象都将引用同一个待处理调用。
[noexcept]
QDBusPendingCall::~QDBusPendingCall()
销毁QDBusPendingCall 对象的此副本。如果该副本也是待处理异步调用的最后一个副本,则该调用将被取消,并且不会再收到任何通知。当回复到达时,将无法访问回复的内容。
[static]
QDBusPendingCall QDBusPendingCall::fromCompletedCall(const QDBusMessage &msg)
根据消息msg 创建QDBusPendingCall 对象。消息必须是QDBusMessage::ErrorMessage 或QDBusMessage::ReplyMessage 类型(即典型的已完成调用消息)。
该函数适用于需要模拟待处理但已结束的调用的代码。
另请参阅 fromError() 。
[static]
QDBusPendingCall QDBusPendingCall::fromError(const QDBusError &error)
根据错误条件创建QDBusPendingCall 对象error 。生成的挂起调用对象将处于 "完成 "状态,QDBusPendingReply<Types...>::isError() 将返回 true。
另请参阅 fromCompletedCall() 。
[noexcept]
void QDBusPendingCall::swap(QDBusPendingCall &other)
将此待处理调用实例与other 互换。这一操作非常快速,从未出现过故障。
QDBusPendingCall &QDBusPendingCall::operator=(const QDBusPendingCall &other)
创建other 待处理异步调用的副本,并删除对先前调用的引用。请注意,使用此函数后,两个对象都将引用同一个待处理调用。
如果该对象包含待处理异步调用的最后一次引用,则该调用将被取消,并且不会再收到任何通知。当回复到达时,将无法访问回复的内容。
© 2025 The Qt Company Ltd. Documentation contributions included herein are the copyrights of their respective owners. The documentation provided herein is licensed under the terms of the GNU Free Documentation License version 1.3 as published by the Free Software Foundation. Qt and respective logos are trademarks of The Qt Company Ltd. in Finland and/or other countries worldwide. All other trademarks are property of their respective owners.