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
注: 型は文字列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 types モジュールをインポートしてください。例えば
syntax = "proto3"; package project.module.component; import "QtCore/QtCore.proto"; message QUrlMessage { QtCore.QUrl url = 1; }
Qt Protobuf ジェネレーターは、ProtobufQtCoreTypes パッケージが提供するQt Core 型を検出し、直接使用します。これにより、追加の変換なしでこれらの型を柔軟に使用できます。
© 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.