IdentifiantMot de passe
Loading...
Mot de passe oublié ?Je m'inscris ! (gratuit)

Qt Remote Objects QML Types

Provides QML types for remote objects support.

Article lu   fois.

L'auteur

Liens sociaux

Viadeo Twitter Facebook Share on Google+   

Qt Remote Objects QML Types

The QML types for Qt Remote Objects provide the helper pieces needed to build a remote objects network. They are typically used in conjunction with custom-registered replica types that make up a specific network.

As an example, consider the following .rep file:

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

The generated replica can be registered as a QML type:

 
Sélectionnez
qmlRegisterType<MyTypeReplica>("custom",1,0,"MyTypeReplica")

And then used from QML in conjunction with the base type Node:

 
Sélectionnez
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")
    }
}

Note that by default you cannot directly assign to a replica property, but rather use a push function. This is due to the potential problems that arise from the mix of declarative programming and asynchronous updates. Specifically, we want to avoid issues like the following:

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

The QML types in this module can be imported into your application using the following import statement in your .qml file:

 
Sélectionnez
import QtRemoteObjects

QML Types

 

Contents

  • Host: A host node on a Qt Remote Objects network.

  • Node: A node on a Qt Remote Objects network.

  • QtRemoteObjects: The QtRemoteObjects global object provides useful functions for working with remote types in QML.

  • SettingsStore: A basic store for persisted properties.

Vous avez aimé ce tutoriel ? Alors partagez-le en cliquant sur les boutons suivants : Viadeo Twitter Facebook Share on Google+