I was upgrading some old code that was working fine to display my qml files inside a QGraphicsScene, but I was using the QDeclarativeView + QGraphicsProxyWidget method, so I converted to the new QT 6.5 / qtquick 2 format using QQuickWidget.
OLD CODE (QT 4.8 / qt quick 1) - Working fine
QGraphicsScene scene;
QML_view = new QDeclarativeView;
QDeclarativeContext *context = QML_view->rootContext();
context->setContextProperty( "Vars_list", QVariant::fromValue( dataList ) );
QML_view->rootContext()->setContextProperty( "myObject", this );
QML_view->setSource( QUrl( "myqmlfile.qml" ) );
QGraphicsProxyWidget *proxy = scene.addWidget( QML_view );
proxy->setZValue( 10 );
NEW CODE (QT 6.5 / qt quick 1)
QGraphicsScene scene;
QQuickWidget *QML_widget = new QQuickWidget();
QQmlContext* context = QML_widget->rootContext();
context->setContextProperty( "Vars_list", QVariant::fromValue( dataList ) );
QML_widget->rootContext()->setContextProperty( "myObject", this );
QML_widget->setSource( QUrl( "myqmlfile.qml" ) );
scene.addWidget( QML_widget );
The qml shows up ok but all the qml buttons are unresponsive, and any existing buttons I may have on my QGraphicsScene show up on top of the qml display too.
So I tried another way replacing scene.addWidget( QML_widget ) with QML_widget->show(). The qml file now works as supposed, but as I was expecting I now have a second separate window opened on the taskbar which I don't want. Any clues about what's the best approach here to fix this issue?