[Interest] QML introspection and dynamic component creation
bo at fioniasoftware.dk
Sat Dec 17 10:15:19 CET 2011
You might have better luck with this question on the QML list.
Den 16-12-2011 12:34, gareth.stockwell at accenture.com skrev:
> I’m working on a piece of UI which would be straightforward to implement
> using an imperative toolkit, but I’m struggling to understand how to
> express it declaratively. Hopefully one of the QML gurus out there can
> show me the way.
Dynamic QML is unfortunately still quite messy. QML is designed for
static interfaces in the sense that it's something that can be described
at compile time. Any kind of dynamic adding of components is just awkward.
I have settled on doing it in C++ instead of QML, because I can more
easily keep track of live objects and delete those no longer used. Also,
I feel I have more control over the creations.
There's a good chance this might change as I get more comfortable with
QML. After all, none of us have much more than a year of QML experience,
but some of us have up to 15 years of Qt/C++ experience. There's still a
lot of experimentation going on. So when you decide how to do it, it
would be great if you could write a blog entry about it - even more so
with the code available.
> When the user selects Wobble from the list of effects, a Loader is used
> to create a WobbleEffect item, and the id of this item is assigned to
> the effect property of the ParameterPanel. What I then want to happen is
> for sliders to be created and connected [...]
As you say, this is pretty easy to do with C++ introspection. So why not
use that? Export a C++ function to QML that does this.
I don't know of a way to do this in QML, but I'd be happy to know. So
anyone with this knowledge, please step up and describe it.
Expert Qt and C++ developer for hire
Contact me if you need expert Qt help
More information about the Interest