Qt Remote Objects QML Types

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

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

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

生成されたレプリカはQMLの型として登録することができます:

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

生成されたレプリカは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

グローバルオブジェクトは、QMLでリモートの型を扱うための便利な機能を提供します。

SettingsStore

永続化されたプロパティの基本ストア

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