RegularExpressionValidator QML Type

文字列バリデータを提供します。詳細...

Import Statement: import QtQuick
In C++: QRegularExpressionValidator

プロパティ

詳細な説明

RegularExpressionValidator 型は、指定した正規表現にマッチする文字列を有効なものとして数えるバリデータを提供します。

IntValidator,DoubleValidator,入力テキストの検証も参照

プロパティの説明

regularExpression : regularExpression

このプロパティはバリデーションに使用する正規表現を保持します。

このプロパティはJS構文の正規表現でなければならないことに注意。

デフォルトでは、このプロパティは、任意の文字列にマッチするパターン.* の正規表現を含みます。

以下に、RegularExpressionValidator が指定されたTextInput オブジェクトの例を示します:

TextInput {
    id: hexNumber
    validator: RegularExpressionValidator { regularExpression: /[0-9A-F]+/ }
}

正規表現の他の例:

  • コンマで区切られた1~3個の数字のリスト:
    /\d{1,3}(?:,\d{1,3})+$/
  • 小数点の前に最大3個の数字、小数点の後に1~2個の数字からなる金額:
    /(\d{1,3})([.,]\d{1,2})?$/

© 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.