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.