On this page

Qt Quick Widgets

To display Qt Quick content in a Qt Widgets application, use QQuickWidget. QQuickWidget is a QWidget that loads and displays a QML file. You can add it to a layout and use it together with other widgets.

The following example adds a QQuickWidget to a widget layout:

#include <QApplication>
#include <QQuickWidget>
#include <QVBoxLayout>
#include <QWidget>

int main(int argc, char *argv[])
{
    QApplication app(argc, argv);

    QWidget window;
    QVBoxLayout *layout = new QVBoxLayout(&window);

    QQuickWidget *quickWidget = new QQuickWidget;
    quickWidget->setSource(QUrl("qrc:/qt/qml/myproject/Main.qml"));
    layout->addWidget(quickWidget);

    window.show();
    return app.exec();
}

Alternatively, you can instantiate QML objects using QQmlComponent and place them in a manually set-up QQuickWidget.

QQuickWidget also manages resizing the view and the root item. By default, the resizeMode is set to SizeViewToRootObject, which resizes the view to the size of the root item. Alternatively, you can set resizeMode to SizeRootObjectToView, which resizes the root item to the size of the view.

Using the Module

Using a Qt module's C++ API requires linking against the module library, either directly or through other dependencies. Several build tools have dedicated support for this, including CMake and qmake.

Building with CMake

Use the find_package() command to locate the needed module component in the Qt6 package:

find_package(Qt6 REQUIRED COMPONENTS QuickWidgets)
target_link_libraries(mytarget PRIVATE Qt6::QuickWidgets)

For more details, see the Build with CMake overview.

Building with qmake quickwidgets

To configure the module for building with qmake, add the module as a value of the QT variable in the project's .pro file:

QT += quickwidgets

Reference

Examples

Licenses and Attributions

Qt Quick Widget is available under commercial licenses from The Qt Company. In addition, it is available under free software licenses. Since Qt 5.4, these free software licenses are GNU Lesser General Public License, version 3, or the GNU General Public License, version 2. See Qt Licensing for more details.

© 2026 The Qt Company Ltd. Documentation contributions included herein are the copyrights of their respective owners. The documentation provided herein is licensed under the terms of the GNU Free Documentation License version 1.3 as published by the Free Software Foundation. Qt and respective logos are trademarks of The Qt Company Ltd. in Finland and/or other countries worldwide. All other trademarks are property of their respective owners.