qtquick-ui-forms.qdoc 3.99 KB
Newer Older
1 2
/****************************************************************************
**
3 4
** Copyright (C) 2016 The Qt Company Ltd.
** Contact: https://www.qt.io/licensing/
5
**
6
** This file is part of the Qt Creator documentation.
7
**
8 9 10 11 12 13 14
** Commercial License Usage
** Licensees holding valid commercial Qt licenses may use this file in
** accordance with the commercial license agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
** a written agreement between you and The Qt Company. For licensing terms
** and conditions see https://www.qt.io/terms-conditions. For further
** information use the contact form at https://www.qt.io/contact-us.
15
**
16
** GNU Free Documentation License Usage
17 18
** Alternatively, this file may be used under the terms of the GNU Free
** Documentation License version 1.3 as published by the Free Software
19 20 21 22
** Foundation and appearing in the file included in the packaging of
** this file. Please review the following information to ensure
** the GNU Free Documentation License version 1.3 requirements
** will be met: https://www.gnu.org/licenses/fdl-1.3.html.
23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40
**
****************************************************************************/

// **********************************************************************
// NOTE: the sections are not ordered by their logical order to avoid
// reshuffling the file each time the index order changes (i.e., often).
// Run the fixnavi.pl script to adjust the links to the index order.
// **********************************************************************

/*!

    \contentspage {Qt Creator Manual}
    \previouspage quick-projects.html
    \page creator-quick-ui-forms.html
    \nextpage creator-using-qt-quick-designer.html

    \title Qt Quick UI Forms

Thomas Hartmann's avatar
Thomas Hartmann committed
41
    You can use \QC wizards to create UI forms that have the filename extension
42
    \e .ui.qml. The UI forms contain a purely declarative subset of the QML
43
    language. It is recommended that you edit the forms in the \uicontrol Design mode.
44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73
    \QC enforces the use of the supported QML features by displaying error
    messages.

    The following features are not supported:

    \list
        \li JavaScript blocks
        \li Function definitions
        \li Function calls (except \c qsTr)
        \li Other bindings than pure expressions
        \li Signal handlers
        \li States in other items than the root item
        \li Root items that are not derived from \l QQuickItem or \l Item
    \endlist

    The following types are not supported:

    \list
        \li Behavior
        \li Binding
        \li Canvas
        \li Component
        \li Shader Effect
        \li Timer
        \li Transform
        \li Transition
    \endlist

    \section1 Using Qt Quick UI Forms

74
    You can edit the forms in the \uicontrol Design mode. Items that are supposed to
75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92
    be used in QML code have to be exported as properties:

    \code
    Item {
        width: 640
        height: 480

        property alias button: button

        Button {
            anchors.centerIn: parent
            id: button
            text: qsTr("Press Me")
        }
    }
    \endcode

    The property alias exports the button to the QML code that uses the form.
93
    You can use the
94
    \inlineimage qmldesigner-export-item-button.png
95 96
    (\uicontrol Export) button in the \uicontrol Navigator to export an item as
    a property:
97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112

    \image qmldesigner-export-item.png

    In the QML file that uses the form, you can use the \c button property alias
    to implement signal handlers, for example. In the following code snippet,
    the UI form is called \e MainForm.ui.qml:

    \code
    MainForm {
        anchors.fill: parent
        button.onClicked: messageDialog.show(qsTr("Button pressed"))
    }
    \endcode

    You can also assign properties or define behavior or transitions.

113 114 115 116
    To move from the \uicontrol Design mode directly to the implementation of a
    type in the .qml file, right-click the type in the \uicontrol Navigator and
    select \uicontrol {Go to Implementation} in the context menu.

117
*/