summaryrefslogtreecommitdiff
path: root/src/controls/doc/src/qtquickcontrols-examples.qdoc
blob: 1a838e0ecd17e01cb1392a1b199aff856151b35b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
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
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
/****************************************************************************
**
** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies).
** Contact: http://www.qt-project.org/legal
**
** This file is part of the documentation of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:FDL$
** 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 Digia.  For licensing terms and
** conditions see http://qt.digia.com/licensing.  For further information
** use the contact form at http://qt.digia.com/contact-us.
**
** GNU Free Documentation License Usage
** Alternatively, this file may be used under the terms of the GNU Free
** Documentation License version 1.3 as published by the Free Software
** 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: http://www.gnu.org/copyleft/fdl.html.
** $QT_END_LICENSE$
**
****************************************************************************/

/*!
    \group qtquickcontrols_examples
    \ingroup all-examples
    \title Qt Quick Controls Examples
    \brief A Collection of examples for \l{Qt Quick Controls}, written in QML.

    These examples show how to create user interfaces using
    \l{Qt Quick Controls}.
*/

/*!
    \example gallery
    \title Qt Quick Controls - Gallery
    \ingroup qtquickcontrols_examples
    \brief A collection of components for a classic desktop-style UI.
    \image qtquickcontrols-example-gallery.png

    This example project demonstrates the various UI components provided by
    \l{Qt Quick Controls}.

    \include examples-run.qdocinc
*/

/*!
    \example basiclayouts
    \title Qt Quick Controls - Basic Layouts Example
    \ingroup qtquickcontrols_examples
    \brief Demonstrates how to use layout types to arrange a UI
    \image qtquickcontrols-example-basiclayouts.png

    This example shows how to easily arrange UI components into
    \l{Qt Quick Layouts}{layouts} with \l{GridLayout}, \l{RowLayout}, and
    \l{ColumnLayout}.

    \include examples-run.qdocinc
*/

/*!
    \example splitview
    \title Qt Quick Controls - Split View Example
    \ingroup qtquickcontrols_examples
    \brief An example for the SplitView UI control.
    \image qtquickcontrols-example-splitview.png

    This example project demonstrates the usage of \l {SplitView} from
    \l{Qt Quick Controls} - a control that lays out items horizontally or
    vertically with a draggable splitter between each item.

    \include examples-run.qdocinc
*/

/*!
    \example tableview
    \title Qt Quick Controls - Table View Example
    \ingroup qtquickcontrols_examples
    \brief An example for the TableView control.
    \image qtquickcontrols-example-tableview.png

    This example shows how a \l{TableView} from \l{Qt Quick Controls}
    can be used together with different types of data models to display
    lists of information with support for scroll bars, selections and
    resizable header sections.

    \include examples-run.qdocinc
*/

/*!
    \example texteditor
    \title Qt Quick Controls - Text Editor Example
    \ingroup qtquickcontrols_examples
    \brief A QML app using Qt Quick Controls and a C++ class to
    provide a fully-functional rich-text editor application.

    \image qtquickcontrols-example-text.png

    The \e{Text Editor Example} presents a sample HTML file using the TextArea
    control, preserving the HTML formatting. It uses a C++ class to handle the
    document by providing options to open, format, and edit. The app also lets
    you open and edit a plain text files.

    The C++ class, DocumentHandler, extends QObject and is registered
    as a QML type under the namespace, "\c{org.qtproject.example 1.0}".

    The following snippets show how the type is registered under
    a namespace and later imported by \e main.qml.

    QML type registration:

    \code
    #include <QtQml/qqml.h>
    ...
    qmlRegisterType<DocumentHandler>("org.qtproject.example", 1, 0, "DocumentHandler");
    ...
    \endcode

    QML namespace import:

    \qml
    import org.qtproject.example 1.0
    \endqml

    For more information about registering C++ classses as QML types, see
    \l {Defining QML Types from C++}.

    \include examples-run.qdocinc
*/

/*!
    \example touch
    \title Qt Quick Controls - Touch Gallery
    \ingroup qtquickcontrols_examples
    \brief Demonstrates UI controls for a touch interface
    \image qtquickcontrols-example-touch.png

    This example shows how to implement a UI suitable
    for touch input using \l{Qt Quick Controls}.

    \include examples-run.qdocinc
*/

/*!
    \example calendar
    \title Qt Quick Controls - Calendar Example
    \ingroup qtquickcontrols_examples
    \brief Demonstrates the use of Calendar control
    \image qtquickcontrols-example-calendar.png

    The Calendar example displays a Calendar control and an events list for
    the selected date. It uses a C++ class to fetch the event details from an
    SQLite database. The example app uses a custom CalendarStyle to highlight
    the selected date and mark the dates that have events.

    The following snippet from \e main.qml shows how the Calendar control is
    used in the app:

    \code
    Calendar {
        id: calendar
        width: (parent.width > parent.height ? parent.width * 0.6 - parent.spacing : parent.width)
        height: (parent.height > parent.width ? parent.height * 0.6 - parent.spacing : parent.height)
        frameVisible: true
        weekNumbersVisible: true
        selectedDate: new Date(2014, 0, 1)
        focus: true

        style: CalendarStyle {
            dayDelegate: Item {
                     ...
                }
           }
    }
    \endcode

    The C++ class, SqlEventModel, inherits SqlQueryModel to create a database
    with dummy events for certain dates.

    \quotefromfile calendar/src/sqleventmodel.cpp
    \skipto SqlEventModel::SqlEventModel()
    \printto QList
    \skipto void SqlEventModel
    \printuntil /\^}

    In \e main.qml, the SqlEventModel custom type is used to get the list of
    events to mark the dates on the calendar.

    \code
    SqlEventModel {
        id: eventModel
    }

    Calendar {
        ...
        style: CalendarStyle {
            dayDelegate: Item {
                ...
                Image {
                    visible: eventModel.eventsForDate(styleData.date).length > 0
                    ...
                    source: "qrc:/images/eventindicator.png"
                }
            }
        }
    }
    \endcode

    The app uses a Flow type to position the items, and manipulates the
    items' width and height based on the orientation change on mobile devices.

    \code
    Calendar {
        id: calendar
        width: (parent.width > parent.height ? parent.width * 0.6 - parent.spacing : parent.width)
        height: (parent.height > parent.width ? parent.height * 0.6 - parent.spacing : parent.height)
    }

    Rectangle {
        width: (parent.width > parent.height ? parent.width * 0.4 - parent.spacing : parent.width)
        height: (parent.height > parent.width ? parent.height * 0.4 - parent.spacing : parent.height)
        border.color: Qt.darker(color, 1.2)

        ListView {
            ...
        }
    }
    \endcode
    \include examples-run.qdocinc
*/