このページでは

RegularExpressionValidator QML Type

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

Import Statement: import QtQuick
In C++: QRegularExpressionValidator

プロパティ

詳細な説明

RegularExpressionValidator 型は、指定された正規表現に一致する文字列をすべて有効とみなすバリデータを提供します。

関連項目: IntValidator 、DoubleValidator 、および「入力テキストの検証」。

プロパティのドキュメント

regularExpression : regularExpression

このプロパティには、検証に使用される正規表現が格納されます。

なお、このプロパティには JavaScript 構文の正規表現を指定する必要があります。例えば、「a」に一致する正規表現は /a/ となります。

デフォルトでは、このプロパティには、任意の文字列に一致する「.* 」というパターンの正規表現が格納されています。

以下に、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})?$/

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