Model-View-Client
Sviluppo di un programma client molto semplice che visualizza i contenuti e le modifiche apportate su un server.
Questa è l'applicazione lato client che accompagna il Model-View Server.
QRemoteObjectNode node(QUrl(QStringLiteral("local:registry")));
node.setHeartbeatInterval(1000);Iniziamo creando un oggetto ` QRemoteObjectNode ` e collegandolo a un registro presente sul computer locale. Impostiamo inoltre un ` heartbeat interval`. L'heartbeat è utile per rilevare se la connessione alla fonte è stata interrotta. In questo caso, poiché tutto il traffico è locale, rileverà quando il server viene chiuso.
QScopedPointer<QAbstractItemModelReplica> model(node.acquireModel(QStringLiteral("RemoteModel")));Successivamente, eseguiamo l’ acquire del modello contenente tutti i nostri dati. In questo caso, intendiamo acquisire un modello denominato RemoteModel dalla rete di oggetti remoti a cui siamo connessi.
QTreeView view;
view.setWindowTitle(QStringLiteral("RemoteView"));
view.resize(640,480);
view.setModel(model.data());
view.show();Infine, visualizziamo il modello in un’applicazione molto semplice.
© 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.