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

Model-View Client

Qt Remote Objects Reference Documentation.

Article lu   fois.

L'auteur

Liens sociaux

Viadeo Twitter Facebook Share on Google+   

Model-View Client

This is the client-side application that accompanies the Model-View Server.

This example showcases how to make a very simple client program which displays the content and changes made on a server.

 
Sélectionnez
    QRemoteObjectNode node(QUrl(QStringLiteral("local:registry")));
    node.setHeartbeatInterval(1000);

We start by creating a QRemoteObjectNode and connecting it to a registry found on the local machine. We also set a heartbeat interval. The heartbeat is useful to detect if the connection to the Source has been disrupted. In this case, since all the traffic is local, it would detect when the server has been closed.

 
Sélectionnez
    QScopedPointer<QAbstractItemModelReplica> model(node.acquireModel(QStringLiteral("RemoteModel")));

We then acquire the model which contains all of our data. In this case, we're looking to acquire a model named RemoteModel from the remote object network we are connected to.

 
Sélectionnez
    QTreeView view;
    view.setWindowTitle(QStringLiteral("RemoteView"));
    view.resize(640,480);
    view.setModel(model.data());
    view.show();

And finally, we display the model in a very basic application.

Example project

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