I have a complex project that relies heavily on QGraphicsScene
and QGraphicsItem
. Different, detailed implementations for multiple types of items, and complex interactions between items on the scene have been carefully designed. The UI around and including the view is created with QWidgets
.
The new requirement is to replace all QWidgets
with a QML front end. I am trying to figure out how to do it. I read multiple posts, suggesting solutions:
- Throw away the
QGraphicItems
and paint pretty squares on a QML scene (as this answer suggests). This may be fine for starting a new project, but not great considering how much work would take, if even possible. - Use QtQuick 1, which supported
QGraphicsScene
integration (as this answer suggests). Does not seem ideal to be stuck with an old version. - "Make the
QGraphicsItems
intoQGraphicsObjects
and expose them to QML." (Placing QGraphicsScene within a QML UI?). This looks most promising but there are no details... I would love to know how to to this. - Use
QQuickWidget
somehow, I am trying to figure it out right now based on this Qt Quick Widgets Example, not getting anywhere though because each "subwindow" is fully separate from all the others.
Please help me find a way to integrate a QGraphicsScene
/ QGraphicsView
in the middle of a qml widget, so that I can keep the old functionality with minimal changes, but change the front end to be full QML. An example would be awesome.