I read another post by wysota about the suitability of QML and it has cast doubt over the future direction I want to take with my app.
In my situation I have a tree model (implemented through QAbstractItemModel) where elements in the tree represent different types of elements. To simplify things, lets just say there's frames, and text. And I want to draw that in a QML scene.
So a frame can have other frames (hence the tree) and text (which is a leaf element). I've been musing on how to do this in QML for a while now - I was thinking I could get around the recursive nature of a tree by essentially proxying it and representing it as a list (and use different indents to make it look like a tree)... but then the type thing has me a bit stumped. I mean if you have an if statement in your delegate, are you trying to do something in a declarative language that isn't really declarative?
I think what wysota is saying is "Yo dude, it's a new technology, but it's not suitable for every use case".
So really, my questions are:
If I have a custom type which I can access via the QModelIndex/QAbstractItemModel data(MyRoles::dataRole), can I do a conditional on the type returned from that in the QML and draw totally different things (e.g. using a loader)? Can I then do a QML equivalent of "dynamic_cast" to get the object I originally put in there and pull out it's data? I know that's kind of what data() is supposed to do, but it means you need a role for every property of every type...
Or is it the wrong technology to be using? Is the fact that I'd be putting in a conditional an indicator that it's not really suitable for a declarative language? Maybe I'd be better off doing something like this in HTML or a graphics scene? The fact that it doesn't really "do" tree's is certainly a warning flag for me.
EDIT: I want to make it quite interactive - reordering via drag/drop of frames etc, hence looking at these solutions.
Bookmarks