QRegExpValidator with QTextEdit

Can QRegExpValidator be used with QTextEdit widgets?

I tried to implement through setValidator (), and also set qtextedit as the parent. But it does not work.

+4
source share
2 answers

You have to use
virtual QValidator::State QRegExpValidator::validate(QString & input, int & pos) const
or
bool QRegExp::exactMatch(const QString & str) const
by yourself. This should not be difficult, you just need to determine where to start the test.

+2
source

You can do the following:

  • define another slot to be called when textChanged () is emitted
  • emit a signal with two parameters (data in qtextedit and length of identical data)
  • connect the validate () slot to the specified slots
-1
source

Source: https://habr.com/ru/post/1489466/


All Articles