Protobuf Qt Core Types Module
프로토버프(protobuf)에서 네이티브 Qt Core 타입을 사용할 수 있도록 지원합니다. 더 보기...
이 모듈은 Qt 6.6에서 도입되었습니다.
상세 설명
Qt::ProtobufQtCoreTypes는 선택된 Qt Core 유형을 캡슐화하도록 설계된, 미리 정의된 protobuf 메시지를 포함하는 라이브러리입니다.
지원되는 Qt Core 유형 목록:
- QByteArray
참고: 유형은 바이트 단위의 protobuf 유형을 반영합니다.
- QChar
- QDate
- QTimeZone
- QDateTime
- QPoint
- QPointF
- QRect
- QRectF
- QSize
- QSizeF
- QString
참고: Type은 protobuf의 문자열 유형을 나타냅니다.
- 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 타깃 속성을 사용하여 라이브러리에서 proto 포함 경로를 추출할 수 있습니다:
qt_add_protobuf(MyProtoLib
PROTO_FILES
MyQtCoreTypesUsage.proto
PROTO_INCLUDES
$<TARGET_PROPERTY:Qt::ProtobufQtCoreTypes,QT_PROTO_INCLUDES>
)© 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.