Add correctly named Q_PROPERTY for repeated message fields
The Qt protobuf generator uses message field names to generate
the corresponding Q_PROPERTY declarations in the message class.
For example, the following proto file:
message Bar {
string name = 1;
Foo foo = 2;
repeated Foo foos = 3;
}
should produce the Bar class with the following properties:
class Bar : ... {
Q_PROPERTY(QString name READ name WRITE setName SCRIPTABLE true)
Q_PROPERTY(messages::Foo foo READ foo WRITE setFoo)
Q_PROPERTY(QList<messages::Foo> foos READ foos WRITE setFoos ...)
...
}
However, the generator incorrectly produced "foosData" instead of "foos"
for repeated message fields:
Q_PROPERTY(QList<messages::Foo> foosData READ foos WRITE setFoos ...)
This broke the user experience by introducing an unexpected suffix.
The fix adds a correctly named Q_PROPERTY for repeated message fields
while keeping the old incorrectly named property for backward compatibility.
The old property should be deprecated, but there is currently no
mechanism to deprecate Q_PROPERTY. See QTBUG-132809.
For now, we can only document the deprecation in code comments.
[ChangeLog][QtProtobuf] Added correctly named Q_PROPERTY declarations
for repeated message fields. The old *Data-suffixed properties are
deprecated and will be removed in Qt 7.
Task-number: QTBUG-145124
Change-Id: Ibafd9ae5f908afca5193f21447a61f617c12946d
Reviewed-by: Dennis Oberst <dennis.oberst@qt.io>
| commit | 3bd1f97a3db50927bbdbf2402e8fcc08c34a8555 |
| parent | 493a7a1e160b2a8edeba89d908102225a00743e7 |
| author | Tatiana Borisova <tatiana.borisova@qt.io> |
| committer | Tatiana Borisova <tatiana.borisova@qt.io> |
| commit time | Thu, 23 Apr 2026 10:40:40 +0000 |
- M src/tools/qtprotobufgen/messagedeclarationprinter.cpp
- M src/tools/qtprotobufgen/messagedefinitionprinter.cpp
- M src/tools/qtprotoccommon/commontemplates.cpp
- M src/tools/qtprotoccommon/commontemplates.h
- M src/tools/qtprotoccommon/generatorcommon.cpp
- M src/tools/qtprotoccommon/generatorcommon.h
- M tests/auto/protobuf/basic/tst_protobuf_repeatedtypes.cpp
- M tests/auto/protobuf/externalpackage/tst_protobuf_externalpackage.cpp
- M tests/auto/protobuf/sequence/tst_protobuf_sequence.cpp
- M tests/auto/protobufgen/data/cmake_generated/export_macro/qtprotobufgen.qpb.cpp
- M tests/auto/protobufgen/data/cmake_generated/export_macro/qtprotobufgen.qpb.h
- M tests/auto/protobufgen/data/cmake_generated/extra_namespace/qtprotobufgen.qpb.cpp
- M tests/auto/protobufgen/data/cmake_generated/extra_namespace/qtprotobufgen.qpb.h
- M tests/auto/protobufgen/data/cmake_generated/generate_package_subfolders/qt/protobuf/qtprotobufgen.qpb.cpp
- M tests/auto/protobufgen/data/cmake_generated/generate_package_subfolders/qt/protobuf/qtprotobufgen.qpb.h
- M tests/auto/protobufgen/data/cmake_generated/no_options/qtprotobufgen.qpb.cpp
- M tests/auto/protobufgen/data/cmake_generated/no_options/qtprotobufgen.qpb.h
- M tests/auto/protobufgen/data/cmake_generated/qml/qtprotobufgen.qpb.cpp
- M tests/auto/protobufgen/data/cmake_generated/qml/qtprotobufgen.qpb.h
- M tests/auto/protobufgen/data/cmake_generated/qml_uri/qtprotobufgen.qpb.cpp
- M tests/auto/protobufgen/data/cmake_generated/qml_uri/qtprotobufgen.qpb.h
- M tests/auto/protobufgen/data/cmake_generated/static/qtprotobufgen.qpb.cpp
- M tests/auto/protobufgen/data/cmake_generated/static/qtprotobufgen.qpb.h
- M tests/auto/protobufgen/data/cmd_line_generated/export_macro/qtprotobufgen.qpb.cpp
- M tests/auto/protobufgen/data/cmd_line_generated/export_macro/qtprotobufgen.qpb.h
- M tests/auto/protobufgen/data/cmd_line_generated/export_macro_custom_file_name/qtprotobufgen.qpb.cpp
- M tests/auto/protobufgen/data/cmd_line_generated/export_macro_custom_file_name/qtprotobufgen.qpb.h
- M tests/auto/protobufgen/data/cmd_line_generated/export_macro_custom_file_name_force_generate/qtprotobufgen.qpb.cpp
- M tests/auto/protobufgen/data/cmd_line_generated/export_macro_custom_file_name_force_generate/qtprotobufgen.qpb.h
- M tests/auto/protobufgen/data/cmd_line_generated/export_macro_custom_file_name_skip_generate/qtprotobufgen.qpb.cpp
- M tests/auto/protobufgen/data/cmd_line_generated/export_macro_custom_file_name_skip_generate/qtprotobufgen.qpb.h
- M tests/auto/protobufgen/data/cmd_line_generated/extra_namespace/qtprotobufgen.qpb.cpp
- M tests/auto/protobufgen/data/cmd_line_generated/extra_namespace/qtprotobufgen.qpb.h
- M tests/auto/protobufgen/data/cmd_line_generated/generate_package_subfolders/qt/protobuf/qtprotobufgen.qpb.cpp
- M tests/auto/protobufgen/data/cmd_line_generated/generate_package_subfolders/qt/protobuf/qtprotobufgen.qpb.h
- M tests/auto/protobufgen/data/cmd_line_generated/no_options/qtprotobufgen.qpb.cpp
- M tests/auto/protobufgen/data/cmd_line_generated/no_options/qtprotobufgen.qpb.h
- M tests/auto/protobufgen/data/cmd_line_generated/qml/qtprotobufgen.qpb.cpp
- M tests/auto/protobufgen/data/cmd_line_generated/qml/qtprotobufgen.qpb.h
- M tests/auto/protobufgen/data/cmd_line_generated/qml_uri/qtprotobufgen.qpb.cpp
- M tests/auto/protobufgen/data/cmd_line_generated/qml_uri/qtprotobufgen.qpb.h
- M tests/auto/protobufgen/data/cmd_line_generated/qml_uri_export_macro/qtprotobufgen.qpb.cpp
- M tests/auto/protobufgen/data/cmd_line_generated/qml_uri_export_macro/qtprotobufgen.qpb.h
- M tests/auto/protobufgen/data/cmd_line_generated/qml_uri_export_macro_generate_package_subfolders/qt/protobuf/qtprotobufgen.qpb.cpp
- M tests/auto/protobufgen/data/cmd_line_generated/qml_uri_export_macro_generate_package_subfolders/qt/protobuf/qtprotobufgen.qpb.h
- M tests/auto/protobufqml/messagelists/qml/tst_repeated.qml