[Interest] [Qt6] Inject a QML enum from C++ at runtime

Konstantin Shegunov kshegunov at gmail.com
Thu Jan 20 15:36:10 CET 2022


Hello,
I imagine I'm not supposed to do such stuff, but is it at all possible to
provide a QML enumerator at runtime from C++?

I took a peek how the QML engine deals with enums, and it does appear it's
technically feasible, provided there's some API, which understandingly
isn't public.
What I'd want to do is to read some configuration file/resource from C++
and fill out a set of named constants in QML based on it.  In C++ I have no
problem indirectly referring to the data, but it'd be advantageous for me
for the QML part to refer to a set of scoped constants by name.
Perhaps I'm thinking in the wrong direction, so if anyone has a suggestion,
it is more than welcome.

Thanks,
Konstantin.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.qt-project.org/pipermail/interest/attachments/20220120/81b8ab26/attachment.htm>


More information about the Interest mailing list