⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 qregexpvalidator.3qt

📁 qt专门用于嵌入式的图形开发GUI
💻 3QT
字号:
'\" t.TH QRegExpValidator 3qt "2 September 2005" "Trolltech AS" \" -*- nroff -*-.\" Copyright 1992-2001 Trolltech AS.  All rights reserved.  See the.\" license file included in the distribution for a complete license.\" statement..\".ad l.nh.SH NAMEQRegExpValidator \- Used to check a string against a.SH SYNOPSIS\fC#include <qvalidator.h>\fR.PPInherits QValidator..PP.SS "Public Members".in +1c.ti -1c.BI "\fBQRegExpValidator\fR ( QObject * parent, const char * name = 0 )".br.ti -1c.BI "\fBQRegExpValidator\fR ( const QRegExp & rx, QObject * parent, const char * name = 0 )".br.ti -1c.BI "\fB~QRegExpValidator\fR ()".br.ti -1c.BI "virtual QValidator::State \fBvalidate\fR ( QString & input, int & pos ) const".br.ti -1c.BI "void \fBsetRegExp\fR ( const QRegExp & rx )".br.ti -1c.BI "const QRegExp & \fBregExp\fR () const".br.in -1c.SH DESCRIPTIONThe QRegExpValidator class is used to check a string against a regular expression..PPQRegExpValidator contains a regular expression, "regexp", used to determine whether an input string is Acceptable, Intermediate or Invalid..PPThe regexp is treated as if it begins with the start of string assertion, \fB^\fR, and ends with the end of string assertion \fB$\fR so the match is against the entire input string, or from the given position if a start position greater than zero is given..PPFor a brief introduction to Qt's regexp engine see QRegExp..PPExample of use:.PP.nf.br    // regexp: optional '-' followed by between 1 and 3 digits.br    QRegExp rx( "-?\\\\d{1,3}" );.br    QValidator* validator = new QRegExpValidator( rx, this );.br.br    QLineEdit* edit = new QLineEdit( this );.br    edit->setValidator( validator );.br.fi.PPBelow we present some examples of validators. In practice they would normally be associated with a widget as in the example above..PP.nf.br    // integers 1 to 9999.br    QRegExp rx( "[1-9]\\\\d{0,3}" );.br    // the validator treats the regexp as "^[1-9]\\\\d{0,3}$".br    QRegExpValidator v( rx, 0 );.br    QString s;.br    int pos = 0;.br.br    s = "0";     v.validate( s, pos );    // returns Invalid.br    s = "12345"; v.validate( s, pos );    // returns Invalid.br    s = "1";     v.validate( s, pos );    // returns Acceptable.br.br    rx.setPattern( "\\\\S+" );            // one or more non-whitespace characters.br    v.setRegExp( rx );.br    s = "myfile.txt";  v.validate( s, pos ); // Returns Acceptable.br    s = "my file.txt"; v.validate( s, pos ); // Returns Invalid.br.br    // A, B or C followed by exactly five digits followed by W, X, Y or Z.br    rx.setPattern( "[A-C]\\\\d{5}[W-Z]" );.br    v.setRegExp( rx );.br    s = "a12345Z"; v.validate( s, pos );        // Returns Invalid.br    s = "A12345Z"; v.validate( s, pos );        // Returns Acceptable.br    s = "B12";     v.validate( s, pos );        // Returns Intermediate.br.br    // match most 'readme' files.br    rx.setPattern( "read\\\\S?me(\\.(txt|asc|1st))?" );.br    rx.setCaseSensitive( FALSE );.br    v.setRegExp( rx );.br    s = "readme";      v.validate( s, pos ); // Returns Acceptable.br    s = "README.1ST";  v.validate( s, pos ); // Returns Acceptable.br    s = "read me.txt"; v.validate( s, pos ); // Returns Invalid.br    s = "readm";       v.validate( s, pos ); // Returns Intermediate.br.fi.PPSee also QRegExp, QIntValidator, QDoubleValidator, and Miscellaneous Classes..SH MEMBER FUNCTION DOCUMENTATION.SH "QRegExpValidator::QRegExpValidator ( QObject * parent, const char * name = 0 )"Constructs a validator that accepts any string (including an empty one) as valid. The object's parent is \fIparent\fR and its name is \fIname\fR..SH "QRegExpValidator::QRegExpValidator ( const QRegExp & rx, QObject * parent, const char * name = 0 )"Constructs a validator which accepts all strings that match the regular expression \fIrx\fR. The object's parent is \fIparent\fR and its name is \fIname\fR..PPThe match is made against the entire string, e.g. if the regexp is \fB[A-Fa-f0-9]+\fR it will be treated as \fB^[A-Fa-f0-9]+$\fR..SH "QRegExpValidator::~QRegExpValidator ()"Destroys the validator, freeing any resources allocated..SH "const QRegExp & QRegExpValidator::regExp () const"Returns the regular expression used for validation..PPSee also setRegExp()..SH "void QRegExpValidator::setRegExp ( const QRegExp & rx )"Sets the regular expression used for validation to \fIrx\fR..PPSee also regExp()..SH "QValidator::State QRegExpValidator::validate ( QString & input, int & pos ) const\fC [virtual]\fR"Returns Acceptable if \fIinput\fR 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 \fIinput\fR is not matched..PPThe \fIpos\fR parameter is set to the length of the \fIinput\fR parameter..PPFor example, if the regular expression is \fB&#92;w&#92;d&#92;d\fR (that is, word-character, digit, digit) then "A57" is Acceptable," E5" is Intermediate and "+9" is Invalid..PPSee also QRegExp::match() and QRegExp::search()..PPReimplemented from QValidator..SH "SEE ALSO".BR http://doc.trolltech.com/qregexpvalidator.html.BR http://www.trolltech.com/faq/tech.html.SH COPYRIGHTCopyright 1992-2001 Trolltech AS, http://www.trolltech.com.  See thelicense file included in the distribution for a complete licensestatement..SH AUTHORGenerated automatically from the source code..SH BUGSIf you find a bug in Qt, please report it as described in.BR http://doc.trolltech.com/bughowto.html .Good bug reports help us to help you. Thank you..PThe definitive Qt documentation is provided in HTML format; it islocated at $QTDIR/doc/html and can be read using Qt Assistant or witha web browser. This man page is provided as a convenience for thoseusers who prefer man pages, although this format is not officiallysupported by Trolltech. .PIf you find errors in this manual page, please report them to.BR qt-bugs@trolltech.com .Please include the name of the manual page (qregexpvalidator.3qt) and the Qtversion (3.3.5).

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -