IntValidator QML Type
定义整数值的验证器。更多
Import Statement: | import QtQuick |
In C++: | QIntValidator |
属性
详细说明
IntValidator 类型为整数值提供了一个验证器。
如果未设置locale ,IntValidator 将使用default locale 来解释数字,并接受特定于本地的数字、组分隔符以及正负号。此外,IntValidator 始终保证接受按照 "C "区域格式化的数字。
下面的示例显示了一个带有 IntValidator 的TextInput 对象,用于检查用户是否输入了指定范围内的整数,并更新文本颜色以突出显示无效输入:
import QtQuick TextInput { focus: true validator: IntValidator { bottom: 0 top: 100 } onAcceptableInputChanged: color = acceptableInput ? "black" : "red"; }
另请参阅 DoubleValidator,RegularExpressionValidator, 以及验证输入文本。
属性文档
bottom : int |
该属性保存验证器可接受的最低值。默认情况下,该属性的值来自可用的最低有符号整数(通常为 -2147483647)。
top : int |
该属性保存验证器的最高可接受值。默认情况下,该属性的值取自可用的最高带符号整数(通常为 2147483647)。
© 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.