gpt4 book ai didi

c++ - 如何使用带有俄文字母的 QLineEdit 掩码?

转载 作者:塔克拉玛干 更新时间:2023-11-03 06:48:30 24 4
gpt4 key购买 nike

我需要 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/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com