The answer to your titular question is, "Yes". I know one way to go about dropping QML into a ui, but I don't know if this helps you:
// inside custom QGraphicsView class...
...
QGraphicsObject *qmlThing
= getQMLGraphicsObjectFromURL
(QUrl("pathToYourURL"));
myScene->addItem(qmlThing);
...
QGraphicsObject * MyGraphicsView
::getQMLGraphicsObjectFromURL(const QUrl &url
) { QDeclarativeComponent component(new QDeclarativeEngine(), url);
QObject *object
= component.
create();
return qobject_cast<QGraphicsObject *>(object);
}
// inside custom QGraphicsView class...
...
QGraphicsObject *qmlThing = getQMLGraphicsObjectFromURL(QUrl("pathToYourURL"));
myScene->addItem(qmlThing);
...
QGraphicsObject * MyGraphicsView::getQMLGraphicsObjectFromURL(const QUrl &url) {
QDeclarativeComponent component(new QDeclarativeEngine(), url);
QObject *object = component.create();
return qobject_cast<QGraphicsObject *>(object);
}
To copy to clipboard, switch view to plain text mode
Bookmarks