QDBusInterface Class
QDBusInterface 클래스는 원격 개체의 인터페이스에 대한 프록시입니다. 더 보기...
헤더: | #include <QDBusInterface> |
CMake: | find_package(Qt6 REQUIRED COMPONENTS DBus) target_link_libraries(mytarget PRIVATE Qt6::DBus) |
qmake: | QT += dbus |
상속합니다: | QDBusAbstractInterface |
공용 함수
QDBusInterface(const QString &service, const QString &path, const QString &interface = QString(), const QDBusConnection &connection = QDBusConnection::sessionBus(), QObject *parent = nullptr) | |
virtual | ~QDBusInterface() |
상세 설명
QDBusInterface는 원격 객체에 대한 호출, 원격 객체가 내보내는 신호에 연결하고 원격 속성 값을 가져오거나 설정하는 데 사용되는 일반 접근자 클래스입니다. 이 클래스는 원격 객체에 대한 동적 액세스, 즉 원격 인터페이스를 나타내는 생성된 코드가 없는 경우에 유용합니다.
호출은 일반적으로 call() 함수를 사용하여 메시지를 구성하고, 버스를 통해 전송하고, 응답을 기다린 후 응답을 디코딩하는 방식으로 이루어집니다. 신호는 일반적인 QObject::connect() 함수를 사용하여 연결됩니다. 마지막으로 QObject::property() 및 QObject::setProperty() 함수를 사용하여 프로퍼티에 액세스합니다.
다음 코드 조각은 세션 버스를 통해 액세스하는 com.example.Calculator
이라는 원격 애플리케이션에서 "2 + 2"
의 수학적 연산을 수행하는 방법을 보여줍니다.
QDBusInterface remoteApp( "com.example.Calculator", "/Calculator/Operations", "org.mathematics.RPNCalculator" ); remoteApp.call( "PushOperand", 2 ); remoteApp.call( "PushOperand", 2 ); remoteApp.call( "ExecuteOperation", "+" ); QDBusReply<int> reply = remoteApp.call( "PopOperand" ); if ( reply.isValid() ) printf( "%d", reply.value() ); // prints 4
Qt D-Bus XML 컴파일러(qdbusxml2cpp)도 참조하세요 .
멤버 함수 문서
QDBusInterface::QDBusInterface(const QString &service, const QString &path, const QString &interface = QString(), const QDBusConnection &connection = QDBusConnection::sessionBus(), QObject *parent = nullptr)
주어진 connection 을 사용하여 서비스 service 의 경로 path 에 있는 객체에 interface 인터페이스와 연결된 동적 QDBusInterface 객체를 생성합니다. interface 이 빈 문자열인 경우, 생성된 객체는 해당 객체를 인트로스펙팅하여 찾은 모든 인터페이스의 병합을 참조합니다. 그렇지 않고 interface 이 비어 있지 않으면, 동일한 인터페이스의 추가 생성 속도를 높이기 위해 QDBusInterface 객체가 캐시됩니다.
parent 는 기본 클래스 생성자에 전달됩니다.
원격 서비스 service 가 없거나 원격 인터페이스 interface 의 설명을 얻으려고 시도하는 동안 오류가 발생하면 생성된 개체는 유효하지 않습니다( isValid() 참조).
[virtual noexcept]
QDBusInterface::~QDBusInterface()
객체 인터페이스를 파괴하고 사용된 모든 리소스를 확보합니다.
© 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.