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.