Stroking lines and custom shapes (polygons) in QML?
-
Hello everyone,
right now I'm experimenting a bit with QML to see if it fits some specific needs of one of my project (mainly navigation elements of the general UI, and some more complex visualization stuff). While the general concept looks very interesting, I can't seem to do a few things.
The first thing I was trying was drawing a simple line between navigation buttons in a vertically aligned (Column element) layout. While there are Elements like "Path" or "PathLine"; they all seem to have alignment of other elements along that specified path in mind.
If that's the case, it surprises me a bit since other primitives like Rectangle are there which can have border colors and fill colors or even gradients.
I don't really want to use SVG either, because I'd have to generate a lot of SVGs for a lot of different types of objects in that visualization. And that would result in a possibly dirtier approach than simply having a QGraphicsScene with custom painting objects.
Thanks in advance!
Basti
-
We've been reluctant to add additional primitives because of speed concerns. For example I wrote an Ellipse element, but it was not accepted since there is no way to make it fast.
However, there is a project that will allow arbitrary things to be drawn into a QML scene, emulating the HTML5 canvas rendering API:
"http://qt.gitorious.org/qt-labs/qmlcanvas":http://qt.gitorious.org/qt-labs/qmlcanvas
You can do a lot of cool things with some imperative drawing code, but you should also be able to write a simple Line component in pure QML based on that.
-
[quote author="Thorbjørn Lindeijer" date="1285697851"]We've been reluctant to add additional primitives because of speed concerns. For example I wrote an Ellipse element, but it was not accepted since there is no way to make it fast.
However, there is a project that will allow arbitrary things to be drawn into a QML scene, emulating the HTML5 canvas rendering API:
"http://qt.gitorious.org/qt-labs/qmlcanvas":http://qt.gitorious.org/qt-labs/qmlcanvas
You can do a lot of cool things with some imperative drawing code, but you should also be able to write a simple Line component in pure QML based on that.[/quote]
Ah, thank you for the response.
In that case I guess I'll just stick with the already imperative approach that I use with a custom QGraphicsItem. I was trying to get rid of all custom imperative drawing by using a QML approach and some internal JavaScript to make it cleaner, but I guess QML has a different focus - and that seems to be UIs for portable devices.