【问题标题】:QLineEdit: How to prevent user from entering asterisk (*)?QLineEdit:如何防止用户输入星号(*)?
【发布时间】:2016-09-14 12:23:59
【问题描述】:

我在我的应用程序中使用 QLineEdit。我想阻止用户在文本的任何地方输入“*”。我尝试使用 QRegExpValidator 但无法设置正确的正则表达式。请帮忙。

【问题讨论】:

  • 无法设置正确的正则表达式 - 你尝试了什么正则表达式?
  • 你有什么代码可以分享吗?

标签: regex qt qlineedit qvalidator


【解决方案1】:

找到解决方案!

QRegExp re("[^*]+");
QRegExpValidator *validator = new QRegExpValidator(re, this);

将此验证器设置为 QLineEdit 就可以了!

【讨论】:

    猜你喜欢
    • 2013-02-28
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2013-12-13
    • 1970-01-01
    • 2014-02-14
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多