当前位置: 首页 > 工具软件 > Inputmask > 使用案例 >

InputMask

东门秦迟
2023-12-01

在UI界面输入栏中,使用InputMask可以限制输入字符;在QT的QLineEdit中,可调用setInputMask方法设置,若想取消掩码可以调用setInputMask("")输入空字符串取消。

关于VBA中的TextBox.InputMask property参见:Link

下表为掩码中可用字符及含义:


Character    Meaning
A            ASCII alphabetic character required. A-Z, a-z.(必须需要ASCII码字符A-Z和a-z)
a            ASCII alphabetic character permitted but not required.(允许但非必需ASCII码字符A-Z和a-z)
N            ASCII alphanumeric character required. A-Z, a-z, 0-9.(必须需要ASCII码字符A-Z和a-z、0-9)
n            ASCII alphanumeric character permitted but not required.(允许但非必需ASCII码字符A-Z和a-z、0-9)
X            Any character required.
x            Any character permitted but not required.
9            ASCII digit required. 0-9.
0            ASCII digit permitted but not required.
D            ASCII digit required. 1-9.
d            ASCII digit permitted but not required (1-9).
#            ASCII digit or plus/minus sign permitted but not required.
H            Hexadecimal character required. A-F, a-f, 0-9.
h            Hexadecimal character permitted but not required.
B            Binary character required. 0-1.
b            Binary character permitted but not required.
>            All following alphabetic characters are uppercased.
<            All following alphabetic characters are lowercased.
!            Switch off case conversion.
[ ] { }      Reserved.
\            Use \ to escape the special characters listed above to use them as separators.

Examples:

 

Mask

Notes

000.000.000.000;_

IP address; blanks are _.

HH:HH:HH:HH:HH:HH;_

MAC address

0000-00-00

ISO Date; blanks are space

>AAAAA-AAAAA-AAAAA-AAAAA-AAAAA;#

License number; blanks are - and all (alphabetic) characters are converted to uppercase.

To get range control (e.g., for an IP address) use masks together with validators.

Access functions:

 

QString

inputMask() const

void

setInputMask(const QString &inputMask)

 类似资料:

相关阅读

相关文章

相关问答