Qt
Internal/Contributor docs for the Qt SDK. Note: These are NOT official API docs; those are found at https://doc.qt.io/
Toggle main menu visibility
Loading...
Searching...
No Matches
qtquickwidgets-index.qdoc
Go to the documentation of this file.
1
// Copyright (C) 2022 The Qt Company Ltd.
2
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GFDL-1.3-no-invariants-only
3
4
/*!
5
\page qtquickwidgets-index.html
6
\title Qt Quick Widgets
7
\brief Provides a C++ widget class for displaying a Qt Quick user interface.
8
9
To display Qt Quick content in a Qt Widgets application, use
10
\l QQuickWidget. \l QQuickWidget is a \l QWidget that loads and displays a
11
QML file. You can add it to a layout and use it together with other widgets.
12
13
The following example adds a \l QQuickWidget to a widget layout:
14
15
\code
16
#include <QApplication>
17
#include <QQuickWidget>
18
#include <QVBoxLayout>
19
#include <QWidget>
20
21
int main(int argc, char *argv[])
22
{
23
QApplication app(argc, argv);
24
25
QWidget window;
26
QVBoxLayout *layout = new QVBoxLayout(&window);
27
28
QQuickWidget *quickWidget = new QQuickWidget;
29
quickWidget->setSource(QUrl("qrc:/qt/qml/myproject/Main.qml"));
30
layout->addWidget(quickWidget);
31
32
window.show();
33
return app.exec();
34
}
35
\endcode
36
37
Alternatively, you can instantiate QML objects using \l QQmlComponent and
38
place them in a manually set-up \l QQuickWidget.
39
40
QQuickWidget also manages resizing the view and the root item. By default,
41
the \l{QQuickWidget::}{resizeMode} is set to
42
\l{QQuickWidget::}{SizeViewToRootObject}, which resizes the view to the size
43
of the root item. Alternatively, you can set \l{QQuickWidget::}{resizeMode}
44
to \l{QQuickWidget::}{SizeRootObjectToView}, which resizes the root item to
45
the size of the view.
46
47
\section1 Using the Module
48
49
\include {module-use.qdocinc} {using the c++ api}
50
51
\section2 Building with CMake
52
53
\include {module-use.qdocinc} {building with cmake} {QuickWidgets}
54
55
\section2 Building with qmake quickwidgets
56
57
\include {module-use.qdocinc} {building_with_qmake} {quickwidgets}
58
59
\section1 Reference
60
61
\list
62
\li \l {Qt Quick Widgets C++ Classes}
63
\endlist
64
65
\section1 Examples
66
67
\list
68
\li \l {Qt Quick Widgets Example}
69
\li \l {QQuickWidget - QQuickView Comparison Example}
70
\li \l {QML Previewer Example}
71
\endlist
72
73
74
\section1 Licenses and Attributions
75
76
Qt Quick Widget is available under commercial licenses from
77
\l{The Qt Company}. In addition, it is available under free software
78
licenses. Since Qt 5.4, these free software licenses are
79
\l{GNU Lesser General Public License, version 3}, or the
80
\l{GNU General Public License, version 2}. See
81
\l{Qt Licensing} for more details.
82
*/
qtdeclarative
src
quickwidgets
doc
src
qtquickwidgets-index.qdoc
Generated on
for Qt by
1.18.0