QDBusPendingCallWatcher Class

QDBusPendingCallWatcher 클래스는 비동기 응답을 기다리는 편리한 방법을 제공합니다. 더 보기...

Header: #include <QDBusPendingCallWatcher>
CMake: find_package(Qt6 REQUIRED COMPONENTS DBus)
target_link_libraries(mytarget PRIVATE Qt6::DBus)
qmake: QT += dbus
상속합니다: QObjectQDBusPendingCall

공용 함수

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()는 참을 반환합니다.

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()도 참조하세요 .

© 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.