모델-뷰-클라이언트

서버에서 발생한 변경 사항과 내용을 표시하는 매우 간단한 클라이언트 프로그램을 개발합니다.

이것은 모델-뷰 서버와 함께 사용되는 클라이언트 측 애플리케이션입니다.

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

먼저 ` QRemoteObjectNode `을 생성하고 이를 로컬 머신에 있는 레지스트리에 연결합니다. 또한 ` heartbeat interval`을 설정합니다. 하트비트는 소스 ( Source )와의 연결이 끊어졌는지 감지하는 데 유용합니다. 이 경우 모든 트래픽이 로컬에서 발생하므로, 서버가 종료되면 이를 감지할 수 있습니다.

    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();

마지막으로, 매우 기본적인 애플리케이션에서 모델을 표시합니다.

예제 프로젝트 @ code.qt.io

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