Is it possible to draw polygons with QML?
-
For example, can I draw a triangle with QML then rotate it using QML features like Transition and State, etc?
-
There is QML open-source APIs called "qmlcanvas":http://qt.gitorious.org/qt-labs/qmlcanvas that might be useful if you insist on drawing with QML. For more info check the "other articles about it at Qt Developer Network":http://qt-project.org/search/tag/qmlcanvas.
-
For sure.
Either create your own QDeclarativeItem / QQuickItem in C++, use the Canvas element in QML (QtQuick 2) or pre-create your polygon in SVG.
-
Or in QtQuick2 you can also create your own custom item by inheriting from QQuickItem (draw using OpenGL) or QQuickPaintedItem (draw using QPainter).
-
Thanks guys. I'm talking about doing it explicitly in QML so I'll definitely check out Canvas. Is it possible to embed Qt Declarative items inside QML Components (a rectangle)?
-
Yes, just make your custom item in C++, register the new type with QML and then instantiate it as a child of a rectangle in your .qml file.
-
Wow, cool. Qt is powerful. Can't wait to have a break from school to have some extensive sessions with Qt...