|
| QRegularExpressionValidator (const QRegularExpression ®Exp, QObject *parent=nullptr) |
|
| QRegularExpressionValidator (QObject *parent=nullptr) |
|
| ~QRegularExpressionValidator () |
|
const QRegularExpression & | regularExpression () const |
|
QValidator::State | validate (QString &input, int &pos) const override |
|
| QValidator (QObject *parent=nullptr) |
|
| ~QValidator () |
|
virtual void | fixup (QString &input) const |
|
QLocale | locale () const |
|
void | setLocale (const QLocale &locale) |
|
| QObject (QObject *parent=nullptr) |
|
| ~QObject () |
|
bool | blockSignals (bool block) |
|
const QList< QObject * > & | children () const |
|
bool | connect (const QObject *sender, const QString &signalMethod, const QString &location, const QString &slotMethod, Qt::ConnectionType type=Qt::AutoConnection) |
|
bool | connect (const QObject *sender, const QString &signalMethod, const QString &slotMethod, Qt::ConnectionType type=Qt::AutoConnection) |
|
bool | disconnect (const QObject *receiver, const QString &slotMethod=QString ()) const |
|
bool | disconnect (const QString &signalMethod, const QString &location, const QObject *receiver=nullptr, const QString &slotMethod=QString ()) const |
|
bool | disconnect (const QString &signalMethod=QString (), const QObject *receiver=nullptr, const QString &slotMethod=QString ()) const |
|
void | dumpObjectInfo () |
|
void | dumpObjectTree () |
|
QList< QString > | dynamicPropertyNames () const |
|
virtual bool | event (QEvent *event) |
|
virtual bool | eventFilter (QObject *watched, QEvent *event) |
|
template<typename T > |
T | findChild (const QString &childName=QString ()) const |
|
template<class T > |
QList< T > | findChildren (const QRegularExpression ®Exp, Qt::FindChildOptions options=Qt::FindChildrenRecursively) const |
|
template<class T > |
QList< T > | findChildren (const QString &childName=QString (), Qt::FindChildOptions options=Qt::FindChildrenRecursively) const |
|
bool | inherits (const QString &className) const |
|
void | installEventFilter (QObject *filterObj) |
|
bool | isWidgetType () const |
|
bool | isWindowType () const |
|
void | killTimer (int id) |
|
const QMetaObject * | metaObject () const |
|
void | moveToThread (QThread *targetThread) |
|
QString | objectName () const |
|
QObject * | parent () const |
|
template<class T = QVariant> |
T | property (const QString &name) const |
|
void | removeEventFilter (QObject *obj) |
|
void | setObjectName (const QString &name) |
|
void | setParent (QObject *parent) |
|
bool | setProperty (const QString &name, const QVariant &value) |
|
bool | signalsBlocked () const |
|
int | startTimer (int interval, Qt::TimerType timerType=Qt::CoarseTimer) |
|
QThread * | thread () const |
|
|
enum | State |
|
static bool | connect (const QObject *sender, const QMetaMethod &signalMethod, const QObject *receiver, const QMetaMethod &slotMethod, Qt::ConnectionType type=Qt::AutoConnection) |
|
static bool | connect (const QObject *sender, const QString &signalMethod, const QObject *receiver, const QString &slotMethod, Qt::ConnectionType type=Qt::AutoConnection, const QString &location=QString ()) |
|
static bool | connect (const QObject *sender, const QString &signalMethod, const QString &location, const QObject *receiver, const QString &slotMethod, Qt::ConnectionType type=Qt::AutoConnection) |
|
template<class Sender , class SignalClass , class... SignalArgs, class Receiver , class SlotClass , class... SlotArgs, class SlotReturn > |
static bool | connect (const Sender *sender, void (SignalClass::*signalMethod)(SignalArgs...), const Receiver *receiver, SlotReturn (SlotClass::*slotMethod)(SlotArgs...), Qt::ConnectionType type=Qt::AutoConnection) |
|
template<class Sender , class SignalClass , class... SignalArgs, class Receiver , class T > |
static bool | connect (const Sender *sender, void (SignalClass::*signalMethod)(SignalArgs...), const Receiver *receiver, T slotLambda, Qt::ConnectionType type=Qt::AutoConnection) |
|
static bool | disconnect (const QObject *sender, const QMetaMethod &signalMethod, const QObject *receiver, const QMetaMethod &slotMethod) |
|
static bool | disconnect (const QObject *sender, const QString &signalMethod, const QObject *receiver, const QString &slotMethod) |
|
static bool | disconnect (const QObject *sender, const QString &signalMethod, const QString &location, const QObject *receiver, const QString &slotMethod) |
|
static bool | disconnect (const QObject *sender, std::nullptr_t, const QObject *receiver, std::nullptr_t) |
|
template<class Sender , class SignalClass , class... SignalArgs, class Receiver , class SlotClass , class... SlotArgs, class SlotReturn > |
static bool | disconnect (const Sender *sender, void (SignalClass::*signalMethod)(SignalArgs...), const Receiver *receiver, SlotReturn (SlotClass::*slotMethod)(SlotArgs...)) |
|
template<class Sender , class SignalClass , class... SignalArgs, class Receiver > |
static bool | disconnect (const Sender *sender, void (SignalClass::*signalMethod)(SignalArgs...), const Receiver *receiver, std::nullptr_t slotMethod=nullptr) |
|
template<class Sender , class SignalClass , class... SignalArgs, class Receiver , class T > |
static bool | disconnect (const Sender *sender, void (SignalClass::*signalMethod)(SignalArgs...), const Receiver *receiver, T slotMethod) |
|
static QMetaObject & | staticMetaObject () |
|
static QString | tr (const char *text, const char *comment=nullptr, std::optional< int > numArg=std::optional< int >()) |
|
virtual void | childEvent (QChildEvent *event) |
|
virtual void | connectNotify (const QMetaMethod &signalMethod) const |
|
virtual void | customEvent (QEvent *event) |
|
virtual void | disconnectNotify (const QMetaMethod &signalMethod) const |
|
bool | isSignalConnected (const QMetaMethod &signalMethod) const |
|
int | receivers (const QString &signal) const |
|
QObject * | sender () const |
|
int | senderSignalIndex () const |
|
virtual void | timerEvent (QTimerEvent *event) |
|
T | qobject_cast (QObject *object) |
|
| QObjectList |
|
The QRegularExpressionValidator class is validate a string based a regular expression. This class uses a regular expression (regexp) to determine whether an input string is Acceptable, Intermediate, or Invalid. The regexp can either be supplied when the QRegularExpressionValidator is constructed or at a later time.
- Note
- In order to use the QRegularExpressionValidator class you will need to include the header <QValidator>.
Regular Expression Matching
If the regexp partially matches against the string, the result is considered Intermediate. For example "" and "A" are Intermediate for the regexp [A-Z][0-9], whereas "_" would be Invalid.
The QRegularExpressionValidator class automatically wraps the regular expression in the \A
and \z
anchors, in other words it always attempts to do an exact match.
Validator Examples
The following regular expression declarations are the setup for the four examples.
Example 1:
str = "0";
v.validate(s, pos);
str = "12345";
v.validate(str, pos);
str = "1";
v.validate(str, pos);
Example 2:
v.setRegularExpression(regExp);
str = "myfile.txt";
v.validate(str, pos);
str = "my file.txt";
v.validate(str, pos);
Example 3:
v.setRegularExpression(regExp);
str = "a12345Z";
v.validate(str, pos);
str = "A12345Z";
v.validate(str, pos);
str = "B12";
v.validate(str, pos);
Example 4:
regExp.
setPattern(
"read\\S?me(\.(txt|asc|1st))?");
v.setRegularExpression(regExp);
str = "readme";
v.validate(str, pos);
str = "README.1ST";
v.validate(str, pos);
str = "read me.txt";
v.validate(str, pos);
str = "readm";
v.validate(str, pos);
- See also
- QRegularExpression, QIntValidator, QDoubleValidator
Returns Acceptable if input is matched by the regular expression for this validator, Intermediate if it has matched partially (i.e. could be a valid match if additional valid characters are added), and Invalid if input is not matched. In case the input is not matched the pos parameter is set to the length of the input parameter otherwise, it is not modified.
As an example, if the regular expression is \w\d\d (word-character, digit, digit) then "A57" is Acceptable, "E5" is Intermediate, and "+9" is Invalid.
- See also
- QRegularExpression::match()
Implements QValidator::validate()