[Interest] [Qt6] Inject a QML enum from C++ at runtime
Konstantin Shegunov
kshegunov at gmail.com
Thu Jan 20 16:59:27 CET 2022
On Thu, Jan 20, 2022 at 5:13 PM Ulf Hermann <ulf.hermann at qt.io> wrote:
> > Well, the number of names isn't fixed is the point - they're loaded at
> > runtime and will change (increase) from time to time.
>
> Then an enumerator won't really help you. The point of an enumerator is
> that each entry is a constant.
>
Each entry is still a constant either way. What I'd intended to provide is
a sort of a "remapping". I simply need stable names from the QML side, that
map to something (as "definitive" as this may sound), which "something" is
going to be mapped to vector indices on the C++ side. The latter (the
vector indices) I must assure are not changed from one version to the next.
While I do still need to provide some convenient API for QML to modify the
value(s). This in a nutshell is what I'm trying to do. Perhaps doing it
with an enum in QML is misguided, I was simply attempting to avoid defining
one such enum in C++ and needing to reship the compiled binary (to a
colleague). Perhaps my whole workflow idea is flawed, I guess.
If the names and values can change at runtime, you should use a
> QVariantMap or a JavaScript object.
>
Yes, I suppose. Perhaps that's what I'm going to do in the end. Thanks for
the input.
If for each version of the program the set of names is fixed, and only
> the values change, then properties on a singleton are the better choice.
>
Actually the other way around (as, described above).
Kind regards,
Konstantin.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.qt-project.org/pipermail/interest/attachments/20220120/8c492f53/attachment.htm>
More information about the Interest
mailing list