#1450

Add support for `Q_CLASSINFO` on qobjects

Openahayzen-kdabopened 5mo ago

Likely add support for a #[q_classinfo("name", "value")] attribute on the qobject (similar to #[qml_element = "name"], this would need the following changes.

  • Add q_classinfo to allowed attrs

https://github.com/KDAB/cxx-qt/blob/2cb6df179b37e760878413d480edd623c61cfdd7/crates/cxx-qt-gen/src/parser/qobject.rs#L50-L61

  • Likely add parsing of the q_classinfo(name, value) to a similar method to parse_qml_metadata, but likely parse_metadata (as this is not limited to only QML, likely have a map of values stored in the ParsedQObject

https://github.com/KDAB/cxx-qt/blob/2cb6df179b37e760878413d480edd623c61cfdd7/crates/cxx-qt-gen/src/parser/qobject.rs#L132-L150

  • Add generation from the map of values to the C++ generation to add Q_CLASSINFO(name, value) to the vector of metaobjects

https://github.com/KDAB/cxx-qt/blob/2cb6df179b37e760878413d480edd623c61cfdd7/crates/cxx-qt-gen/src/generator/cpp/qobject.rs#L63-L83

  • Add extra unit tests to cover the cases

  • Add documentation to the extern "RustQt" book page

Discussed in https://github.com/KDAB/cxx-qt/discussions/1447

Originally posted by MolotovCherry May 7, 2026 In c++ we can do Q_CLASSINFO("DefaultProperty", "propertyName"), but I can't find any way to do this purely on the rust side without writing a c++ wrapper (this is useful for children)

Activity

0

No activity yet.