QML Previewer Example

Demonstrates how to mix Qt Quick with a Qt Widgets application using QWidget::createWindowContainer().

QML code editor with live preview panel

The example demonstrates how you can embed Qt Quick scenes inside a Qt Widgets application, and how different UI aspects integrate between Qt Widgets and Qt Quick. This includes:

  • Tab focusing between Qt Widgets and Qt Quick
  • Drag and drop between Qt Widgets and Qt Quick
  • Shortcuts defined in the embedded QML file
  • Embedding a QQuickView inside a QLayout

Running the Example

You can run the example from:

UI walkthrough

The main window of the example contains a file browser on the left side, which allows you to select QML files to preview. The right side displays the QML content in a QQuickWidget. You can interact with the QML content, including clicking buttons, entering text, and using shortcuts defined in the QML files.

The example also demonstrates how to handle focus and input events between the Qt Widgets and Qt Quick components, ensuring a smooth user experience.

Example project @ code.qt.io

See also QWidget::createWindowContainer().