[Previous: Mouse Events] [Next: Keyboard Focus]
QML provides several elements to display text onto the screen. The Text element will display formatted text onto the screen, the TextEdit element will place a multiline line edit onto the screen, and the TextInput will place a single editable line field onto the screen.
To learn more about their specific features and properties, visit their respective element documentation.
The validator elements enforce the type and format of TextInput objects.
Column { spacing: 10 Text { text: "Enter a value from 0 to 2000" } TextInput { focus: true validator: IntValidator { bottom:0; top: 2000} } }
The validator elements bind to TextInput's validator property.
Column { spacing: 10 Text { text: "Which basket?" } TextInput { focus: true validator: RegExpValidator { regExp: /fruit basket/ } } }
The regular expression in the snippet will only allow the inputted text to be fruit basket.
Note that QML parses JavaScript regular expressions, while Qt's QRegExp class' regular expressions are based on Perl regular expressions.
[Previous: Mouse Events] [Next: Keyboard Focus]
© 2008-2011 Nokia Corporation and/or its subsidiaries. Nokia, Qt and their respective logos are trademarks of Nokia Corporation in Finland and/or other countries worldwide.
All other trademarks are property of their respective owners. Privacy Policy
Licensees holding valid Qt Commercial licenses may use this document in accordance with the Qt Commercial License Agreement provided with the Software or, alternatively, in accordance with the terms contained in a written agreement between you and Nokia.
Alternatively, this document may be used under the terms of the GNU Free Documentation License version 1.3 as published by the Free Software Foundation.