시간 클라이언트 애플리케이션
서버에서 시간 개체의 복제본을 보관하고 시계에 시간을 표시하는 클라이언트입니다.
시간 클라이언트 애플리케이션은 메시지와 함께 파란색 창을 엽니다. 한 번 클릭하면 시계가 표시됩니다. 다시 클릭하면 두 개의 시계가 표시되고 반복됩니다. 시계는 Clock.qml에 정의되어 있으며, 서버의 시간을 사용하여 시계의 시간을 설정하기 위해 C++로 구현된 Time
QML 유형을 사용합니다.
시간 클라이언트 애플리케이션을 실행하기 전
이 예제를 실행하려면 시간 서버 애플리케이션이 이 애플리케이션과 동일한 호스트에서 이미 실행 중이어야 합니다. 이 애플리케이션은 레지스트리 서버를 설정하고 MinuteTimerSimpleSource
클래스의 하위 클래스 인스턴스를 호스팅합니다. 실행 중이 아닌 경우 창에 오류 메시지가 표시됩니다.
REP 파일을 사용하여 원격 객체 정의하기
이 애플리케이션의 상위 디렉터리에 있는 REP 파일 "timemodel.rep"는 두 애플리케이션에서 사용하는 헤더 파일을 생성하는 데 사용됩니다. 이 애플리케이션의 경우 생성된 "rep_timemodel_replica.h" 파일은 MinuteTimerReplica
, MinuteTimer
의 복제본 및 기타 관련 클래스를 정의합니다.
타임모델 클래스
plugin.h 및 plugin.cpp의 TimeModel
클래스는 QML 유형 Time
을 구현합니다. 이 클래스는 URL "local:registry"를 사용하여 localhost의 레지스트리 서버에 연결하고 복제본( MinuteTimerReplica
)을 가져온 다음 해당 신호에 연결합니다. 프로퍼티는 자동으로 업데이트됩니다.
QML 유형
"Clock.qml"에 정의된 QML은 시간 및 분 속성을 사용하여 시계를 그립니다.
애플리케이션은 "plugins.qml" 콘텐츠가 있는 창을 엽니다. 이 창은 로더를 사용하여 다른 콘텐츠를 표시하고, 클릭할 때마다 "plugins0.qml", "plugins1.qml", "plugins2.qml" 사이를 순환하며 변경됩니다.
"plugins0.qml"은 메시지와 함께 파란색 화면을 표시하는 반면, "plugins1.qml"에서는 사용자 정의 QML 유형 Clock
이 사용되며, 시간 및 분 속성은 Time
의 시간 및 분 속성으로 설정됩니다. "plugins2.qml" 파일은 비슷하지만 두 개의 시계를 표시합니다.
import QtRemoteObjects import QtQuick import TimeExample // import types from the plugin Rectangle { width: 200 height: 400 color: "blue" Clock { id: clock1 anchors.top: parent.top Time { // this class is defined in C++ id: time node: node } Node { id: node registryUrl: "local:registry" } hours: time.hour minutes: time.minute valid: time.state == Time.Valid } }
시간 서버 애플리케이션도참조하세요 .
© 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.