このページでは

Qt Remote Objects QML Types

以下のQML型は Qt Remote Objects は、リモートオブジェクトネットワークを構築するために必要な補助的な要素を提供します。これらは通常、特定のネットワークを構成する、カスタム登録されたレプリカ型と組み合わせて使用されます。

例として、以下の .rep ファイルを考えてみましょう。

class MyType {
    PROP(QString myProp="Hello World")
};

生成されたレプリカは、QML タイプとして登録できます:

qmlRegisterType<MyTypeReplica>("custom",1,0,"MyTypeReplica")

そして、基底型である Node と組み合わせて QML から使用できます:

import QtQuick
import QtRemoteObjects
import custom 1.0

Item {
    MyTypeReplica {
        id: myType
        node: Node { registryUrl: "local:registry" }
    }

    Text { text: myType.myProp }

    MouseArea {
        anchors.fill: parent
        onClicked: myType.pushMyProp("Updated Text")
    }
}

デフォルトでは、レプリカのプロパティに直接代入することはできず、代わりにpush 関数を使用する必要がある点に注意してください。これは、宣言型プログラミングと非同期更新が混在することで生じる可能性のある問題によるものです。具体的には、次のような問題を回避したいからです:

myType.myProp = "Updated Text"
console.log(myType.myProp) // logs "Hello World", as the new text has not yet been round-tripped

このモジュールに含まれる QML タイプは、.qml ファイルで以下の import ステートメントを使用することで、アプリケーションにインポートできます:

import QtRemoteObjects

QML 型

Host

Qt Remote Objects ネットワーク上のホストノード

Node

Qt Remote Objects ネットワーク上のノード

QtRemoteObjects

Globalオブジェクトは、QMLでリモート型を扱う際に役立つ関数を提供します

SettingsStore

永続化プロパティ用の基本的なストア

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