QML and protobuf: Issue with repeated nested message
-
Hi,
I'm having some trouble using a repeated nested message as a property from C++ in QML, for example
syntax = "proto3"; package messages; message Foo { string name = 1; } message Bar { string name = 1; Foo foo = 2; repeated Foo foos = 3; repeated string baz = 4; }being exposed as a property from C++ as
#ifndef BACKEND_H #define BACKEND_H #include <QObject> #include <QQmlEngine> #include "messages.qpb.h" class Backend : public QObject { Q_OBJECT QML_ELEMENT Q_PROPERTY(messages::Bar bar MEMBER bar_ WRITE setBar NOTIFY barChanged); public: explicit Backend(QObject *parent = nullptr); void setBar(messages::Bar bar); signals: void barChanged(messages::Bar); private: messages::Bar bar_; }; #endif // BACKEND_Hand in QML
import QtQuick import QtQuick.Controls Window { width: 640 height: 480 visible: true title: qsTr("Hello World") Label { text: { print(backend.bar) print(backend.bar.foo) print(backend.bar.foos) print(backend.bar.baz) return "Bar name: " + backend.bar.name } } }This results in "foos" being undefined in QML, the other fields work as expected. Seems like a bug? I created a minimal reproducing example here. I'm using Qt 6.10.2 on Debian 13. Any advice on how to proceed would be appreciated.
//Daniel