QDBusPendingCallWatcher Class
QDBusPendingCallWatcher 클래스는 비동기 응답을 기다리는 편리한 방법을 제공합니다. 더 보기...
| 헤더: | #include <QDBusPendingCallWatcher> |
| CMake: | find_package(Qt6 REQUIRED COMPONENTS DBus) target_link_libraries(mytarget PRIVATE Qt6::DBus) |
| qmake: | QT += dbus |
| 상속: | QObject 그리고 QDBusPendingCall |
공개 함수
| QDBusPendingCallWatcher(const QDBusPendingCall &call, QObject *parent = nullptr) | |
| virtual | ~QDBusPendingCallWatcher() |
| bool | isFinished() const |
| void | waitForFinished() |
신호
| void | finished(QDBusPendingCallWatcher *self = nullptr) |
상세 설명
QDBusPendingCallWatcher는 응답이 도착하면 발송되는 finished() 신호를 제공합니다.
일반적으로 다음 예제와 같이 사용됩니다.
QDBusPendingCall async = iface->asyncCall("RemoteMethod", value1, value2);
QDBusPendingCallWatcher *watcher = new QDBusPendingCallWatcher(async, this);
QObject::connect(watcher, &QDBusPendingCallWatcher::finished, this,
&DBus_PendingCall_Interface::callFinishedSlot);QDBusPendingCallWatcher도 해당 클래스를 상속받고 있으므로, 원래의 ` QDBusPendingCall ` 객체를 따로 유지할 필요는 없습니다.
위 코드에 연결된 슬롯은 다음과 유사할 수 있습니다:
void DBus_PendingCall_Interface::callFinishedSlot(QDBusPendingCallWatcher *call)
{
QDBusPendingReply<QString, QByteArray> reply = *call;
if (reply.isError()) {
showError();
} else {
QString text = reply.argumentAt<0>();
QByteArray data = reply.argumentAt<1>();
showReply(text, data);
}
call->deleteLater();
}응답의 인자 유형을 검증하기 위해 ` QDBusPendingReply `를 사용하는 점에 유의하십시오. 응답에 정확히 두 개의 인자(문자열 하나와 ` QByteArray` 하나)가 포함되지 않은 경우, ` QDBusPendingReply::isError()`는 true를 반환합니다.
QDBusPendingReply도 참조하십시오 .
멤버 함수 문서
[explicit] QDBusPendingCallWatcher::QDBusPendingCallWatcher(const QDBusPendingCall &call, QObject *parent = nullptr)
비동기 대기 중인 호출 call 에 대한 응답을 감시하기 위해 QDBusPendingCallWatcher 객체를 생성하고, 이 객체의 부모를 parent 로 설정합니다.
[virtual noexcept] QDBusPendingCallWatcher::~QDBusPendingCallWatcher()
이 객체를 삭제합니다. 이 ` QDBusPendingCallWatcher ` 객체가 완료되지 않은 대기 중인 호출에 대한 마지막 참조인 경우, 해당 호출이 취소됩니다.
[signal] void QDBusPendingCallWatcher::finished(QDBusPendingCallWatcher *self = nullptr)
이 신호는 대기 중인 호출이 완료되고 해당 응답을 확인할 수 있게 되었을 때 발생합니다. ` self ` 매개변수는 객체 자체에 대한 포인터로, 슬롯이 속성에 접근하여 응답의 내용을 확인할 수 있도록 편의를 위해 전달됩니다.
bool QDBusPendingCallWatcher::isFinished() const
대기 중인 호출의 처리가 완료되고 응답을 수신한 경우 ` true `를 반환합니다.
이 함수는 waitForFinished()를 호출하거나 외부 D-Bus 이벤트가 발생했을 때만 상태를 변경하며, 일반적으로는 이벤트 루프 실행으로 돌아갈 때만 발생한다는 점에 유의하십시오.
QDBusPendingReply::isFinished()도 참조하십시오 .
void QDBusPendingCallWatcher::waitForFinished()
응답을 수신하고 처리할 때까지 호출 스레드의 실행을 일시 중지합니다. 이 함수가 반환된 후, ` isFinished()`는 `true`를 반환해야 하며, 이는 응답의 내용을 처리할 준비가 되었음을 나타냅니다.
QDBusPendingReply::waitForFinished()도 참조하십시오 .
© 2026 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.