Protobuf Qt Core Types Module
프로토뷰에서 네이티브 Qt Core 유형 사용을 지원합니다. 더 보기...
이 모듈은 Qt 6.6에 도입되었습니다.
자세한 설명
Qt::ProtobufQtCoreTypes는 선택된 Qt Core 형을 캡슐화하도록 설계된 사전 정의된 protobuf 메시지가 있는 라이브러리입니다.
지원되는 Qt Core 형의 목록:
- QByteArray
참고: 타입은 바이트 프로토뷰프 타입을 반영합니다.
- QChar
- QDate
- QTimeZone
- QDateTime
- QPoint
- QPointF
- QRect
- QRectF
- QSize
- QSizeF
- QString
참고: 유형은 문자열 프로토뷰 유형을 반영합니다.
- QTime
- QUrl
- QUuid
- QVersionNumber
Qt Core 사용법
Qt Core 유형 지원을 활성화하려면 CMake 프로젝트에 ProtobufQtCoreTypes를 종속성으로 추가하세요:
... find_package(Qt REQUIRED COMPONENTS Protobuf ProtobufQtCoreTypes) ... # After target creation target_link_libraries(${TARGET} PRIVATE Qt::ProtobufQtCoreTypes)
Qt Core 유형을 필드로 사용하는 메시지를 직렬화하거나 역직렬화하기 전에 등록 메서드를 호출하세요:
// e.g. in main.cpp QtProtobuf::qRegisterProtobufQtCoreTypes(); ...
지원되는 모든 메시지는 Qt Core 모듈의 Qt 유형을 설명하는 특수 .proto 파일( QtCore.proto)에 설명되어 있습니다.
이 파일을 사용하여 다른 언어나 프레임워크용 코드를 생성할 수도 있습니다.
인터페이스 .proto 파일에서 필요한 Qt Core 유형 모듈을 가져옵니다. 예를 들어
syntax = "proto3"; package project.module.component; import "QtCore/QtCore.proto"; message QUrlMessage { QtCore.QUrl url = 1; }
Qt Protobuf 생성기는 ProtobufQtCoreTypes 패키지에서 제공하는 Qt Core 유형을 감지하고 이를 직접 사용합니다. 따라서 추가 변환 없이 이러한 유형을 유연하게 사용할 수 있습니다.
CMake에서는 QT_PROTO_INCLUDES
대상 속성을 사용하여 라이브러리에서 프로토 포함 경로를 추출할 수 있습니다:
qt_add_protobuf(MyProtoLib PROTO_FILES MyQtCoreTypesUsage.proto PROTO_INCLUDES $<TARGET_PROPERTY:Qt::ProtobufQtCoreTypes,QT_PROTO_INCLUDES> )
© 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.