[Interest] Mixing QWidgets and QtQuickControls 2

Benjamin TERRIER b.terrier at gmail.com
Fri Nov 11 20:00:26 CET 2022


On Fri, 11 Nov 2022 at 14:10, Harald Vistnes <harald.vistnes at gmail.com>
wrote:

>
>
> 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
> directly?
>
>
There are many ways to do that not sure which one is best, but I will share
what I generally do:


   1. When I want to integrate QML in a widget app, I generally use
   QQuickWIdget.
   2. For dialogs:
   - either I use a QDialog and I integrate the QQuickWidget as any other
      widget
      - or I implement a QuickDialog which is a subclass of QQuickView with
      some QDialog-like functions (exec(), accept(), etc.)
      3. I never use Window or ApplicationWindow QML types, because, as you
   have experienced, you get 2 windows: one from the QQuickView and a second
   one from the Window QML type.

>From my experience this gives the best controls and ease of use, but of
course there are some exceptions.
Also, it is possible to replace QQuickWidget by a QQuickView combined with
QWidget::createWindowContainer().

I only use QQmlApplicationEngine and Window QML types when writing pure Qt
Quick applications.

Regards

Benjamin
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.qt-project.org/pipermail/interest/attachments/20221111/528850ef/attachment.htm>


More information about the Interest mailing list