モデルビュークライアント
サーバー上で行われたコンテンツや変更を表示する、非常にシンプルなクライアントプログラムを開発する。
これは、Model-View Serverに付随するクライアント側のアプリケーションです。
QRemoteObjectNode node(QUrl(QStringLiteral("local:registry"))); node.setHeartbeatInterval(1000);
まず、QRemoteObjectNode を作成し、ローカルマシンのレジストリに接続します。また、heartbeat interval 。ハートビートは、ソースへの接続が切断されたかどうかを検出するのに便利です。この場合、トラフィックはすべてローカルなので、サーバーが閉じられたことを検知する。
QScopedPointer<QAbstractItemModelReplica> model(node.acquireModel(QStringLiteral("RemoteModel")));
次に、acquire 、すべてのデータを含むモデルを作成します。この場合、RemoteModel
という名前のモデルを、接続しているリモート・オブジェクト・ネットワークから取得します。
QTreeView view; view.setWindowTitle(QStringLiteral("RemoteView")); view.resize(640,480); view.setModel(model.data()); view.show();
そして最後に、非常に基本的なアプリケーションでモデルを表示する。
© 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.