PDA

View Full Version : Construct dynamically a QML element



keyga
21st April 2013, 14:38
Hi everyone,

I'm wondering how I can define a new QML element that need some "treatments" to be constructed.
For example I want draw a compass, so it's not a basic Rectangle.. Obviously, I'm not going to define each line manually, I need kind of a loop which deals with an incremented angle value and so on...

What would be the syntax ? Thank you for your help :) I just begin QML language so I have none experience...

http://www.fondation-lamap.org/sites/default/files/upload/media/ressources/activites/11349/1040_seq4sea8_3.gif

Bye ;)

wysota
21st April 2013, 22:44
To be honest this kind of compass should be drawn in QtQuick using an image. I'm not saying you can't do that in pure QML but I think it's not worth the effort.

keyga
21st April 2013, 23:45
Thank you for your answer :)

After some search i've seen that it's indeed not appropriate in pure classic QML. But what about redefining a custom QQuickItem, i've seen that i can use pure OpenGL code in it. At the end I would obtain a QML component ready to use.
Is that a good approach?

wysota
22nd April 2013, 06:51
After some search i've seen that it's indeed not appropriate in pure classic QML. But what about redefining a custom QQuickItem, i've seen that i can use pure OpenGL code in it. At the end I would obtain a QML component ready to use.
Is that a good approach?

As I said, it is not impossible to obtain but it is much more work than drawing such compass in a graphics editor and rendering it as an image.