How to add QML widgets in QGraphicsScene version QtQuick 2.0
-
Hi everyone! how to add qml widget in QGraphicsScene version QtQuick 2.0? In The documentation only found out how to add widgets version QtQuick 1.0, and version QtQuick 2.0 no.
@QGraphicsScene* scene = myExistingGraphicsScene();
QDeclarativeEngine *engine = new QDeclarativeEngine;
QDeclarativeComponent component(engine, QUrl::fromLocalFile("myqml.qml"));
QGraphicsObject *object =
qobject_cast<QGraphicsObject *>(component.create());
scene->addItem(object);@ -
Good, because it can't be done ;)
QtQuick 1 is based on QGraphicsView, so integrating it with QGraphicsScene is possible. QtQuick 2 uses entirely separate graphics stack.
-
I don't know why are you using QGraphicsScene, so I don't know which of the alternatives to offer. To combine QtWidgets with QtQuick module, you need to take a look at "createWindowContainer":http://qt-project.org/doc/qt-5.1/qtwidgets/qwidget.html#createWindowContainer() function.