gemmell
2nd February 2013, 11:01
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.
If most of functionality of your application is related to dragging static objects on some canvas, setting their properties, doing things like copy & paste, undo&redo, etc. then QtQuick doesn't have much to offer in this regard. It's about DECLARING things to happen. You can't really predeclare situations that heavily depend on the logic. I'm not saying it is not possible to do what you want with QtQuick (see the link at the end of my post), I'm just saying it will probably take you much time without any real benefits.
http://www.youtube.com/watch?v=kvWeE3kurEQ
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 (http://www.qtcentre.org/threads/35816-Using-an-If-condition-in-a-QML-delegate))? 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.
If most of functionality of your application is related to dragging static objects on some canvas, setting their properties, doing things like copy & paste, undo&redo, etc. then QtQuick doesn't have much to offer in this regard. It's about DECLARING things to happen. You can't really predeclare situations that heavily depend on the logic. I'm not saying it is not possible to do what you want with QtQuick (see the link at the end of my post), I'm just saying it will probably take you much time without any real benefits.
http://www.youtube.com/watch?v=kvWeE3kurEQ
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 (http://www.qtcentre.org/threads/35816-Using-an-If-condition-in-a-QML-delegate))? 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.