![]() |
CopperSpice API
1.7.4
|
Validates a string based on a regular expression. More...
Public Signals | |
void | regularExpressionChanged (const QRegularExpression ®Exp) |
![]() | |
void | changed () |
![]() | |
void | destroyed (QObject *obj=nullptr) |
void | objectNameChanged (const QString &objectName) |
Public Slots | |
void | setRegularExpression (const QRegularExpression ®Exp) |
![]() | |
void | deleteLater () |
Public Methods | |
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 &objName=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 |
Properties | |
regularExpression | |
![]() | |
objectName | |
Additional Inherited Members | |
![]() | |
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.
QRegularExpressionValidator 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.
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.
QRegularExpressionValidator automatically wraps the regular expression in the \A
and \z
anchors, in other words it always attempts to do an exact match.
The following regular expression declarations are the setup for the four examples.
Example 1:
Example 2:
Example 3:
Example 4:
|
explicit |
Constructs a validator with a parent object that accepts any string (including an empty one) as valid.
|
explicit |
Constructs a validator with a parent object that accepts all strings that match the regular expression regExp.
QRegularExpressionValidator::~QRegularExpressionValidator | ( | ) |
Destroys the validator.
const QRegularExpression & QRegularExpressionValidator::regularExpression | ( | ) | const |
Retrieves the regular expression saved with setRegularExpression().
|
signal |
This signal is emitted when the value of the regular expression is changed.
|
slot |
Stores regExp with the option QPatternOption::ExactMatchOption enabled. The regular expression is used when validating input to the validate() method.
|
overridevirtual |
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.
Implements QValidator.
|
This property holds the regular expression used for validation. By default this property contains a regular expression with an empty pattern (which therefore matches any string).
Properties | Class Methods |
---|---|
read | regularExpression |
write | setRegularExpression |
notify | regularExpressionChanged |