1// Copyright (C) 2017 The Qt Company Ltd.
2// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GFDL-1.3-no-invariants-only
5 \qmlmodule QtQuick.Controls
6 \keyword Qt Quick Controls QML Types
7 \title Qt Quick Controls QML Types
8 \keyword Qt Quick Controls 2 QML Types
10 \brief Provides QML types for user interfaces (Qt Quick Controls).
12 \l{Qt Quick Controls} provides QML types for creating user interfaces.
13 These QML types work in conjunction with \l{Qt Quick} and
16 Qt Quick Controls QML types can be imported into your application
17 using the following import statement in your .qml file:
20 import QtQuick.Controls
24 \generatelist {qmltypesbymodule QtQuick.Controls}
27 \section1 Using Qt Quick Controls types in property declarations
29 As mentioned in \l {Qt Quick Templates 2 QML Types}, each type in Qt Quick
30 Controls is backed by a C++ "template" type. These types are \l {Qt Quick
31 Templates 2}{non-visual implementations of controls' logic and behavior}.
33 For example, the \l Menu type's API and behavior is defined by the C++
34 type in Qt Quick Templates. Each \l {Definition of a Style}{style} that
35 wants to provide a Menu must have a Menu.qml available, and the root
36 item in that file must be the Menu from Qt Quick Templates. When you
37 import QtQuick.Controls and create a Menu in QML, the type you get is
38 actually the QML Menu defined by the style's Menu.qml.
40 In order to use a control as the type in a property declaration, you should
41 use the corresponding type from Qt Quick Templates. For example, suppose
42 you had a \c PopupOpener component, which was a Button that opened a
47 import QtQuick.Controls
50 required property Popup popup
52 onClicked: popup.open()
57 popup: saveChangesDialog
67 Running this code will result in an error:
70 Unable to assign Dialog_QMLTYPE to Popup_QMLTYPE
73 This is because of the inheritance hierarchy:
76 Popup (C++ type in QtQuick.Templates)
77 │ └── Popup (QML type in QtQuick.Controls)
78 └── Dialog (C++ type in QtQuick.Templates)
79 └── Dialog (QML type in QtQuick.Controls)
82 Dialog from \c QtQuick.Controls does not derive from the Popup from
83 \c QtQuick.Controls, but from \c QtQuick.Templates.
85 Instead, use the Popup from Qt Quick Templates as the property type:
89 import QtQuick.Controls
90 import QtQuick.Templates as T
93 required property T.Popup popup
95 onClicked: popup.open()
99 For more information on the Qt Quick Controls module, see the
100 \l {Qt Quick Controls} module documentation.
102 \section1 Related Information
104 \li \l {Qt Quick Controls Guidelines}