How to integrate QGraphicsView with QML.
My requirement is to draw some objects, like Line, Rect, and Circle.
I know the alternative way using Canvas, QPaintedItem etc.
But my thought is like, if we can integrate the QGraphicsView and QGraphicsScene with QML we can have very easy handling for graphic objects (with the help of QGraphicsLineItem......etc ). I tried to integrate this with QML by exposing the class which uses QGraphicView QGraphicScene and QGraphicsLineItem but something went wrong (I dont know whether its is possible or not).
@Praveen-kk Hi! unfortunately it's no longer possible to integrate widgets into a QtQuick scene. It was possible with QtQuick 1.
Thank you Wieland..!
Any way can you tell me why they removed it from QtQuick 2. Am expecting your valuable suggestions on my issue. What is the better way to implement this kind of stuff in QML, also i may be required to save my object co-ordinates to back end database. Can you suggest me a good method to doing this.?
QtQuick 1 was itself based on QGraphicsScene. This is why one could integrate QWidgets into a scene. The downside of this was the poor performance so QtQuick 2 was completely rewritten and has its own high-performance rendering stack which sits directly on top of OpenGL.
Your options are...
- Create lines, rectangles, circles etc as QtQuick items.
- Create a single QQuickPaintedItem to draw lines, rectangles, circles etc.
- Create a single QQuickItem to draw lines, rectangles, circles etc.
- Use a single QtQuick Canvas item to draw lines, rectangles, circles etc.
Create lines, rectangles, circles etc as QtQuick items.
Create a single QQuickPaintedItem to draw lines, rectangles, circles etc.
Create a single QQuickItem to draw lines, rectangles, circles etc.
Dear Wieland ,
Can I get a sample for the above, Actually i am facing issue with line object. It will draw inside a rectangular area, so it is difficult to handle multiple objects.