Mixing QML GUI and GraphicsView painting
-
Hi,
I want to write something like a game for children. The background shall be something like a cheat of paper.
The users can paint on it like in Scribble. Additionally they can insert elements like shapes and more complex elements modeled in Qml. Last but not least it wouldl be great to add Flash content as well.I guess I have to use a QGraphicsView / ~scene and insert the Qml elements as GraphicsItem, so that it is possible to zoom in and out, change the z-order of the elements, so that the paintings can lay above as well as under the Qml elements. Am not sure if Flash can be handled in the same way.
Is the direction right or am I missing something? Do you have maybe some additional hints or links about this topic? I just used Google too, but without the right questions it is difficult to get the right answers :)
Thanks in advance!
Micha -
To be honest I am not sure how you would go about having an item you can paint on within QML - well I have a very vague notion but it is so vague it is not worth mentioning.
I would go for QGraphicsView/Scene for this application. Just use QGraphicsPixmapItem (or svg based item) for your pre-defined shapes etc.
-
I think not specifically. I think it is doable with a custom QML item but not trivial. You would need a custom item that would need to track mouse movements following a mouse down event. During the drag your custom item would need to adjust its bounding rect as well as keep painting itself.
Since you will be doing all this in the C++ side of things anyway I just suggested doing the whole scene management in QGraphicsView.
-
I would start by trying to port the "Scribble":http://doc.qt.nokia.com/latest/widgets-scribble-scribblearea-h.html example that ships with Qt to QGraphicsView and take it from there.