- Qt 6.12
- Qt Quick
- QQuickWidget - QQuickView Comparison Example
- Qt 6.12.0 Reference Documentation

# QQuickWidget - QQuickView Comparison Example

Demonstrates the benefits of QQuickWidget over a QQuickView embedded as a native window.

The example allows showing the same Qt Quick scene within the same QWidget-based user interface using two different approaches:

- Using a QQuickView.

  It is used as a child window and with QWidget::createWindowContainer()

- Using QQuickWidget.

  Acts as a true QWidget and supports, among others, better clipping and stacking, as is expected from a true QWidget.

Clicking on the Show widget overlay checkbox demonstrates a widget stacking case that is not rendering as expected when embedding a native window, while QQuickWidget makes it render as expected.

#### Running the Example

To run the example from Qt Creator, open the Welcome mode and select the example from Examples. For more information, see Qt Creator: Tutorial: Build and run.

#### Platform notes

The Qt Quick scene uses direct OpenGL rendering, even when embedded with QQuickWidget. This confirms that rendering continues to use the accelerated 3D API.

Therefore, the example is tied to OpenGL and won't work with other graphics APIs such as Vulkan, Metal, or Direct3D.

#### Multisample antialiasing

You can enable multisample antialiasing by selecting the corresponding checkbox. When enabled, QQuickWidget renders content into a multisample renderbuffer. After each render pass, the content is resolved into a standard 2D texture. This enables antialiasing for Qt Quick content without affecting the rest of the QWidget-based UI.

If you're using QQuickView, the native window requests multisampling for its surface. This provides similar results, depending on platform support.

#### Keyboard input

The Qt Quick scene supports user interaction, including text input, regardless of the embedding technology used. When using QQuickWidget, input events are automatically forwarded to the Qt Quick scene.

Example project @ code.qt.io

See also Qt Quick Widgets.