QT的QRegularExpressionValidator类的使用

详细说明
QRegularExpressionValidator类用于根据正则表达式检查字符串。

QRegularExpressionValidator使用正则表达式(regexp)来确定输入字符串是“可接受”,“中间”还是“无效”。可以在构造QRegularExpressionValidator时或在以后的时间提供regexp。
如果正则表达式与字符串部分匹配,则结果被视为中间。例如,“”和“ A”是正则表达式[A-Z] [0-9]的中间字符(而“ _”将是无效的)。
QRegularExpressionValidator自动将正则表达式包装在\ A和\ z锚点中;换句话说,它总是尝试进行精确匹配。
使用示例:

  // regexp: optional '-' followed by between 1 and 3 digits
  QRegularExpression rx("-?\\d{1,3}");
  QValidator *validator 

你可能感兴趣的:(QT完整教程)