[Interest] Mixing QWidgets and QtQuickControls 2

Harald Vistnes harald.vistnes at gmail.com
Fri Nov 11 14:09:33 CET 2022


I have a quite big QWidgets based application and I am considering
migrating portions of it to use Qt Quick Controls 2. I'm new to
QML/QtQuick, so I decided to start very simple and test how to migrate my
About dialog (QDialog).

I tried replacing

AboutDialog dlg(this);


    auto *widget = new QQuickWidget();
    widget->setResizeMode(QQuickWidget::SizeRootObjectToView );

This sort of worked. But if I in my QML used a Window or Dialog as root
entity, 2 windows opened, a black window for the QQuickWidget and another
window with the about dialog. If I changed the root entity to a Rectangle
instead, then the about QML was drawn in the correct window.

However, I have a Close button that should close the dialog. This has no
effect right now. I haven't found a way to connect the click on the close
button to the closing of the QQuickWidget.

So the question is, what is the best way for migrating a QWidgets based
dialog to a Qt Quick Controls based dialog? Should I not use QQuickWidget
for standalone dialogs, but instead trigger the QML in another way? Or
embed the QQuickWidget inside a QDialog? Or use QQmlApplicationEngine

Best regards,
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.qt-project.org/pipermail/interest/attachments/20221111/4e17673a/attachment.htm>

More information about the Interest mailing list