Qt Quick テキスト入力処理とバリデータ
テキスト視覚タイプ
Qt Quick は、テキストを画面に表示するためのいくつかの型を提供します。 タイプは書式付きテキストを画面に表示し、 タイプは複数行の編集を画面に配置し、 は編集可能な単一行のフィールドを画面に配置します。Text TextEdit TextInput
それぞれの機能とプロパティの詳細については、それぞれのドキュメントを参照してください。
入力テキストのバリデーション
バリデータの型は、TextInput オブジェクトの型とフォーマットを強制します。
整数以外の数値用のバリデータを定義します。 | |
整数値用のバリデータを定義します。 | |
文字列バリデータ |
Column { spacing: 10 Text { text: "Enter a value from 0 to 2000" } TextInput { focus: true validator: IntValidator { bottom:0; top: 2000} } }
バリデータの型はTextInput
のvalidator
プロパティにバインドします。
Column { spacing: 10 Text { text: "Which basket?" } TextInput { focus: true validator: RegularExpressionValidator { regularExpression: /fruit basket/ } } }
このスニペットの正規表現は、入力されたテキストをfruit basket
にすることだけを許可します。
Qt のQRegularExpression クラスの正規表現は Perl の正規表現に基づいています。
© 2025 The Qt Company Ltd. Documentation contributions included herein are the copyrights of their respective owners. The documentation provided herein is licensed under the terms of the GNU Free Documentation License version 1.3 as published by the Free Software Foundation. Qt and respective logos are trademarks of The Qt Company Ltd. in Finland and/or other countries worldwide. All other trademarks are property of their respective owners.