Show Qml file in QGraphicsView
I have a QGraphicsView and I want to add a qml file in it as part of scene.
I used following code but nothing is shown in scene, just a gray rectangle
QQuickView *view = new QQuickView; view->setSource(QUrl("qrc:/qml/SettingsButton.qml")); QWidget *container = QWidget::createWindowContainer(view); container->setMinimumSize(150, 50); QGraphicsProxyWidget * item = scene->addWidget(/*(QWidget *)*/container);
What's wrong with this code?
SettingsButton.qml has an
Itemas root and some rectangles and images.
QGraphics*classes only work with QtQuick 1.x.
@p3c0 so how can I embed qml file in qgraphics framework?
QQuickWidgetto load the QML and since
QWidgetyou can use
QGraphicsProxyWidgetto embed it.