1 /****************************************************************************
3 ** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
4 ** All rights reserved.
5 ** Contact: Nokia Corporation (qt-info@nokia.com)
7 ** This file is part of the documentation of the Qt Toolkit.
9 ** $QT_BEGIN_LICENSE:FDL$
10 ** GNU Free Documentation License
11 ** Alternatively, this file may be used under the terms of the GNU Free
12 ** Documentation License version 1.3 as published by the Free Software
13 ** Foundation and appearing in the file included in the packaging of
17 ** Alternatively, this file may be used in accordance with the terms
18 ** and conditions contained in a signed written agreement between you
26 ****************************************************************************/
29 \page texthandling.html
30 \inqmlmodule QtQuick 2
31 \title QML Text Handling and Validators
33 \previouspage {QML Mouse Events}{Mouse Events}
34 \nextpage {Keyboard Focus in QML}{Keyboard Focus}
35 \contentspage QML Features
39 \section1 Text Elements
50 \o \l{DoubleValidator}
51 \o \l{RegExpValidator}
54 \section1 Displaying Text in QML
55 QML provides several elements to display text onto the screen. The \l Text
56 element will display formatted text onto the screen, the \l TextEdit element
57 will place a multiline line edit onto the screen, and the \l TextInput will
58 place a single editable line field onto the screen.
60 To learn more about their specific features and properties, visit their
61 respective element documentation.
63 \section1 Validating Input Text
64 The \l {Validators}{validator} elements enforce the type and format of
67 \snippet doc/src/snippets/declarative/texthandling.qml int validator
68 The validator elements bind to \c {TextInput}'s \c validator property.
70 \snippet doc/src/snippets/declarative/texthandling.qml regexp validator
71 The regular expression in the snippet will only allow the inputted text to be
74 Note that QML parses JavaScript regular expressions, while Qt's
75 \l {QRegExp} class' regular expressions are based on Perl regular expressions.