我需要 QLineEdit
的大小写始终较低。我将把它与俄语字母一起使用。
最佳答案
您可以简单地应用“toLower”原则,尽管不适用于QString
,因为它始终使用“C”语言环境处理,但根据Qt文档,QLocale
:
QString QLocale::toLower(const QString & str) const
Returns a lowercase copy of str. This function was introduced in QtCore 4.8.
如果您愿意,您也可以将 QValidator
用于 QLineEdit
(基于您的“初始请求”):
void QValidator::setLocale(const QLocale & locale)
Sets the locale that will be used for the validator. Unless setLocale has been called, the validator will use the default locale set with QLocale::setDefault(). If a default locale has not been set, it is the operating system's locale.
和:
State QValidator::validate(QString & input, int & pos) const [pure virtual]
This virtual function returns Invalid if input is invalid according to this validator's rules, Intermediate if it is likely that a little more editing will make the input acceptable (e.g. the user types "4" into a widget which accepts integers between 10 and 99), and Acceptable if the input is valid. The function can change both input and pos (the cursor position) if required.
一旦您拥有自己的验证器实现,您就可以使用以下 QLineEdit
setter 来实际使用您的验证:
void QLineEdit::setValidator(const QValidator * v)
Sets this line edit to only accept input that the validator, v, will accept. This allows you to place any arbitrary constraints on the text which may be entered. If v == 0, setValidator() removes the current input validator. The initial setting is to have no input validator (i.e. any input is accepted up to maxLength()).
关于c++ - 如何使用带有俄语字母的 QLineEdit 蒙版?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19196089/