Exposing a custom data type to QML
-
Qt Version is 6.7.2.
What I'm looking for is essentially to have a struct or class, e.g.
typedef struct CustomType { Q_GADGET QString customValue; // Q_PROPERTY stuff here... }
and then declare it to Qt in such a way that I can have a variable -- NOT a component -- with that type, and be able to explicitly declare it as such, i.e.
Item { property CustomType customType Component.onCompleted: { customType.customValue = "Test Value" console.log(customType.customValue, typeof customType) // Test Value CustomType } }
In essence, bringing my own custom types into QML land much like QRect -> rect, QColor -> color, etc. but NOT as a component as the documentation outlines.
How would I go about doing this?
-
-
@Asperamanca Wow--I completely missed that--yes, that will work! Thanks.
-