Show Qml file in QGraphicsView
-
Hi.
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 rectangleQQuickView *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
Item
as root and some rectangles and images.Thanks
-
@MajidKamali
QGraphics*
classes only work with QtQuick 1.x. -
@p3c0 so how can I embed qml file in qgraphics framework?
-
@MajidKamali Use
QQuickWidget
to load the QML and sinceQQuickWidget
inheritsQWidget
you can useQGraphicsProxyWidget
to embed it.