Sophie

Sophie

distrib > Mandriva > 2010.0 > i586 > media > contrib-release > by-pkgid > a6711891ce757817bba854bf3f25205a > files > 2178

qtjambi-doc-4.3.3-3mdv2008.1.i586.rpm

<class name="QRegExpValidator" doc="/**
&lt;p&gt;The &lt;a href=&quot;QRegExpValidator.html#QRegExpValidator(com.trolltech.qt.core.QRegExp, com.trolltech.qt.core.QObject)&quot;&gt;&lt;tt&gt;QRegExpValidator&lt;/tt&gt;&lt;/a&gt; class is used to check a string against a regular expression.&lt;/p&gt;
&lt;p&gt;&lt;a href=&quot;QRegExpValidator.html#QRegExpValidator(com.trolltech.qt.core.QRegExp, com.trolltech.qt.core.QObject)&quot;&gt;&lt;tt&gt;QRegExpValidator&lt;/tt&gt;&lt;/a&gt; uses a regular expression (regexp) to determine whether an input string is &lt;a href=&quot;QValidator.html#State-enum&quot;&gt;Acceptable&lt;/tt&gt;&lt;/a&gt;, &lt;a href=&quot;QValidator.html#State-enum&quot;&gt;Intermediate&lt;/tt&gt;&lt;/a&gt;, or &lt;a href=&quot;QValidator.html#State-enum&quot;&gt;Invalid&lt;/tt&gt;&lt;/a&gt;. The regexp can either be supplied when the &lt;a href=&quot;QRegExpValidator.html#QRegExpValidator(com.trolltech.qt.core.QRegExp, com.trolltech.qt.core.QObject)&quot;&gt;&lt;tt&gt;QRegExpValidator&lt;/tt&gt;&lt;/a&gt; is constructed, or at a later time.&lt;/p&gt;
&lt;p&gt;When &lt;a href=&quot;QRegExpValidator.html#QRegExpValidator(com.trolltech.qt.core.QRegExp, com.trolltech.qt.core.QObject)&quot;&gt;&lt;tt&gt;QRegExpValidator&lt;/tt&gt;&lt;/a&gt; determines whether a string is &lt;a href=&quot;QValidator.html#State-enum&quot;&gt;Acceptable&lt;/tt&gt;&lt;/a&gt; or not, the regexp is treated as if it begins with the start of string assertion (&lt;b&gt;^&lt;/b&gt;) and ends with the end of string assertion (&lt;b&gt;$&lt;/b&gt;); the match is against the entire input string, or from the given position if a start position greater than zero is given.&lt;/p&gt;
&lt;p&gt;If a string is a prefix of an &lt;a href=&quot;QValidator.html#State-enum&quot;&gt;Acceptable&lt;/tt&gt;&lt;/a&gt; string, it is considered &lt;a href=&quot;QValidator.html#State-enum&quot;&gt;Intermediate&lt;/tt&gt;&lt;/a&gt;. For example, &amp;quot;&amp;quot; and &amp;quot;A&amp;quot; are &lt;a href=&quot;QValidator.html#State-enum&quot;&gt;Intermediate&lt;/tt&gt;&lt;/a&gt; for the regexp &lt;b&gt;[A-Z][0-9]&lt;/b&gt; (whereas &amp;quot;_&amp;quot; would be &lt;a href=&quot;QValidator.html#State-enum&quot;&gt;Invalid&lt;/tt&gt;&lt;/a&gt;).&lt;/p&gt;
&lt;p&gt;For a brief introduction to Qt's regexp engine, see &lt;a href=&quot;%2E%2E/core/QRegExp.html&quot;&gt;&lt;tt&gt;QRegExp&lt;/tt&gt;&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;Example of use:&lt;/p&gt;
&lt;pre&gt;&lt;span class=&quot;comment&quot;&gt;    // regexp: optional '-' followed by between 1 and 3 digits&lt;/span&gt;
    QRegExp rx(&amp;quot;-?\\d{1,3}&amp;quot;);
    QValidator *validator = new QRegExpValidator(rx, this);

    QLineEdit *edit = new QLineEdit(this);
    edit-&amp;gt;setValidator(validator);&lt;/pre&gt;
&lt;p&gt;Below we present some examples of validators. In practice they would normally be associated with a widget as in the example above.&lt;/p&gt;
&lt;pre&gt;&lt;span class=&quot;comment&quot;&gt;    // integers 1 to 9999&lt;/span&gt;
    QRegExp rx(&amp;quot;[1-9]\\d{0,3}&amp;quot;);
&lt;span class=&quot;comment&quot;&gt;    // the validator treats the regexp as &amp;quot;^[1-9]\\d{0,3}$&amp;quot;&lt;/span&gt;
    QRegExpValidator v(rx, 0);
    QString s;
    int pos = 0;

    s = &amp;quot;0&amp;quot;;     v.validate(s, pos);    &lt;span class=&quot;comment&quot;&gt;// returns Invalid&lt;/span&gt;
    s = &amp;quot;12345&amp;quot;; v.validate(s, pos);    &lt;span class=&quot;comment&quot;&gt;// returns Invalid&lt;/span&gt;
    s = &amp;quot;1&amp;quot;;     v.validate(s, pos);    &lt;span class=&quot;comment&quot;&gt;// returns Acceptable&lt;/span&gt;

    rx.setPattern(&amp;quot;\\S+&amp;quot;);            &lt;span class=&quot;comment&quot;&gt;// one or more non-whitespace characters&lt;/span&gt;
    v.setRegExp(rx);
    s = &amp;quot;myfile.txt&amp;quot;;  v.validate(s, pos); &lt;span class=&quot;comment&quot;&gt;// Returns Acceptable&lt;/span&gt;
    s = &amp;quot;my file.txt&amp;quot;; v.validate(s, pos); &lt;span class=&quot;comment&quot;&gt;// Returns Invalid&lt;/span&gt;

&lt;span class=&quot;comment&quot;&gt;    // A, B or C followed by exactly five digits followed by W, X, Y or Z&lt;/span&gt;
    rx.setPattern(&amp;quot;[A-C]\\d{5}[W-Z]&amp;quot;);
    v.setRegExp(rx);
    s = &amp;quot;a12345Z&amp;quot;; v.validate(s, pos);        &lt;span class=&quot;comment&quot;&gt;// Returns Invalid&lt;/span&gt;
    s = &amp;quot;A12345Z&amp;quot;; v.validate(s, pos);        &lt;span class=&quot;comment&quot;&gt;// Returns Acceptable&lt;/span&gt;
    s = &amp;quot;B12&amp;quot;;     v.validate(s, pos);        &lt;span class=&quot;comment&quot;&gt;// Returns Intermediate&lt;/span&gt;

&lt;span class=&quot;comment&quot;&gt;    // match most 'readme' files&lt;/span&gt;
    rx.setPattern(&amp;quot;read\\S?me(\.(txt|asc|1st))?&amp;quot;);
    rx.setCaseSensitive(false);
    v.setRegExp(rx);
    s = &amp;quot;readme&amp;quot;;      v.validate(s, pos); &lt;span class=&quot;comment&quot;&gt;// Returns Acceptable&lt;/span&gt;
    s = &amp;quot;README.1ST&amp;quot;;  v.validate(s, pos); &lt;span class=&quot;comment&quot;&gt;// Returns Acceptable&lt;/span&gt;
    s = &amp;quot;read me.txt&amp;quot;; v.validate(s, pos); &lt;span class=&quot;comment&quot;&gt;// Returns Invalid&lt;/span&gt;
    s = &amp;quot;readm&amp;quot;;       v.validate(s, pos); &lt;span class=&quot;comment&quot;&gt;// Returns Intermediate&lt;/span&gt;&lt;/pre&gt;

@see &lt;a href=&quot;%2E%2E/core/QRegExp.html&quot;&gt;&lt;tt&gt;QRegExp&lt;/tt&gt;&lt;/a&gt;
@see &lt;a href=&quot;QIntValidator.html&quot;&gt;&lt;tt&gt;QIntValidator&lt;/tt&gt;&lt;/a&gt;
@see &lt;a href=&quot;QDoubleValidator.html&quot;&gt;&lt;tt&gt;QDoubleValidator&lt;/tt&gt;&lt;/a&gt;
@see Settings Editor Example&lt;/tt&gt; */">
    <method name="public QRegExpValidator(com.trolltech.qt.core.QObject parent)" doc="/**
&lt;p&gt;Constructs a validator with a &lt;tt&gt;parent&lt;/tt&gt; object that accepts any string (including an empty one) as valid.&lt;/p&gt;
 */"/>
    <method name="public QRegExpValidator(com.trolltech.qt.core.QRegExp rx, com.trolltech.qt.core.QObject parent)" doc="/**
&lt;p&gt;Constructs a validator with a &lt;tt&gt;parent&lt;/tt&gt; object that accepts all strings that match the regular expression &lt;tt&gt;rx&lt;/tt&gt;.&lt;/p&gt;
&lt;p&gt;The match is made against the entire string; e.g&amp;#x2e; if the regexp is &lt;b&gt;[A-Fa-f0-9]+&lt;/b&gt; it will be treated as &lt;b&gt;^[A-Fa-f0-9]+$&lt;/b&gt;.&lt;/p&gt;
 */"/>
    <method name="public final com.trolltech.qt.core.QRegExp regExp()" doc="/**
&lt;p&gt;Returns the regular expression used for validation.&lt;/p&gt;

@see &lt;a href=&quot;QRegExpValidator.html#setRegExp(com.trolltech.qt.core.QRegExp)&quot;&gt;&lt;tt&gt;setRegExp&lt;/tt&gt;&lt;/a&gt; */"/>
    <method name="public final void setRegExp(com.trolltech.qt.core.QRegExp rx)" doc="/**
&lt;p&gt;Sets the regular expression used for validation to &lt;tt&gt;rx&lt;/tt&gt;.&lt;/p&gt;

@see &lt;a href=&quot;QRegExpValidator.html#regExp()&quot;&gt;&lt;tt&gt;regExp&lt;/tt&gt;&lt;/a&gt; */"/>
    <method name="public com.trolltech.qt.gui.QValidator.State validate(com.trolltech.qt.gui.QValidator.QValidationData input)" doc="/**
&lt;p&gt;Equivalent to &lt;a href=&quot;QRegExpValidator.html#validate(com.trolltech.qt.gui.QValidator.QValidationData)&quot;&gt;validate&lt;/tt&gt;&lt;/a&gt;(&lt;tt&gt;input&lt;/tt&gt;, ). */"/>
</class>