이 페이지에서

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()

객체 인터페이스를 파기하고 사용 중인 모든 리소스를 해제합니다.

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