DoubleValidator QML Type
非整数のバリデータを定義する。詳細...
Import Statement: | import QtQuick |
In C++: | QDoubleValidator |
プロパティ
詳細な説明
DoubleValidator 型は、非整数のバリデータを提供します。
- 受け付ける入力:入力が有効な範囲内にあり、かつ正しい形式の double を含む場合に入力を受け付ける。
- 入力は受け付けるが無効なもの:入力は受け付けるが、有効範囲外の double を含むか間違った形式 (たとえば小数点以下の桁数が多すぎるか空白) の場合は無効とする。
- 拒否された入力:入力がdoubleでない場合は拒否される。
注: 有効範囲が正の倍数(例えば、0.0~100.0)のみで構成され、入力が負の倍数の場合、入力は拒否される。notation がDoubleValidator.StandardNotation
に設定され、入力に小数点以下の桁数が有効範囲内の double の桁数より多い場合も拒否される。notation がDoubleValidator.ScientificNotation
であり、入力が有効範囲にない場合、その値は受理されるが無効である。指数を変更することで、有効な値になる可能性があります。
次の例では、TextInput オブジェクトに DoubleValidator を指定し、ユーザが指定された範囲内で double を入力したかどうかをチェックし、テキストの色を更新して無効な入力を強調表示しています:
import QtQuick TextInput { focus: true validator: DoubleValidator { bottom: 0.00 top: 100.00 decimals: 2 notation: DoubleValidator.StandardNotation } onAcceptableInputChanged: color = acceptableInput ? "black" : "red"; }
IntValidator,RegularExpressionValidator,入力テキストの検証も参照してください 。
プロパティの説明
bottom : real |
このプロパティはバリデータの最小許容値を保持します。デフォルトでは、このプロパティには -infinity が設定される。
decimals : int |
このプロパティには、バリデータの小数点以下の桁数の最大値を設定します。デフォルトでは、このプロパティの値は 1000 である。
notation : enumeration |
このプロパティは、文字列が数値をどのように表現できるかの表記法を保持する。
このプロパティに指定できる値は以下のとおりです:
定数 | 説明 |
---|---|
DoubleValidator.StandardNotation | オプションの符号を持つ 10 進数のみ (例:-0.015 ) |
DoubleValidator.ScientificNotation | (デフォルト) 記述された数値は指数部を持つことができる (例:1.5E-2 ) |
top : real |
このプロパティはバリデータの最大許容値を保持する。デフォルトでは、このプロパティには無限大の値が格納される。
© 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.