Sophie

Sophie

distrib > Mageia > 4 > i586 > by-pkgid > 28b9e36e96ce34b2567ae5b47a27b2c5 > files > 966

python-qt4-doc-4.10.3-3.mga4.noarch.rpm

<?xml version="1.0" encoding="iso-8859-1"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "DTD/xhtml1-strict.dtd">
<html><head><title>QRegExpValidator Class Reference</title><style>h3.fn,span.fn { margin-left: 1cm; text-indent: -1cm }
a:link { color: #004faf; text-decoration: none }
a:visited { color: #672967; text-decoration: none }
td.postheader { font-family: sans-serif }
tr.address { font-family: sans-serif }
body { background: #ffffff; color: black; }
</style></head><body><table border="0" cellpadding="0" cellspacing="0" width="100%"><tr /><td align="left" valign="top" width="32"><img align="left" border="0" height="32" src="images/rb-logo.png" width="32" /></td><td width="1">&#160;&#160;</td><td class="postheader" valign="center"><a href="index.html"><font color="#004faf">Home</font></a>&#160;&#183; <a href="classes.html"><font color="#004faf">All Classes</font></a>&#160;&#183; <a href="modules.html"><font color="#004faf">Modules</font></a></td></table><h1 align="center">QRegExpValidator Class Reference<br /><sup><sup>[<a href="qtgui.html">QtGui</a> module]</sup></sup></h1><p>The QRegExpValidator class is used to check a string against a
regular expression. <a href="#details">More...</a></p>

<p>Inherits <a href="qvalidator.html">QValidator</a>.</p><h3>Methods</h3><ul><li><div class="fn" /><b><a href="qregexpvalidator.html#QRegExpValidator">__init__</a></b> (<i>self</i>, QObject&#160;<i>parent</i>&#160;=&#160;None)</li><li><div class="fn" /><b><a href="qregexpvalidator.html#QRegExpValidator-2">__init__</a></b> (<i>self</i>, QRegExp&#160;<i>rx</i>, QObject&#160;<i>parent</i>&#160;=&#160;None)</li><li><div class="fn" />QRegExp <b><a href="qregexpvalidator.html#regExp">regExp</a></b> (<i>self</i>)</li><li><div class="fn" /><b><a href="qregexpvalidator.html#setRegExp">setRegExp</a></b> (<i>self</i>, QRegExp&#160;<i>rx</i>)</li><li><div class="fn" />(QValidator.State, QString&#160;<i>input</i>, int&#160;<i>pos</i>) <b><a href="qregexpvalidator.html#validate">validate</a></b> (<i>self</i>, QString&#160;<i>input</i>, int&#160;<i>pos</i>)</li><li><div class="fn" />(QValidator.State, int&#160;<i>pos</i>) <b><a href="qregexpvalidator.html#validate-2">validate</a></b> (<i>self</i>, QString&#160;<i>input</i>, int&#160;<i>pos</i>)</li></ul><a name="details" /><hr /><h2>Detailed Description</h2><p>The QRegExpValidator class is used to check a string against a
regular expression.</p>
<p>QRegExpValidator uses a regular expression (regexp) to determine
whether an input string is <a href="qvalidator.html#State-enum">Acceptable</a>, <a href="qvalidator.html#State-enum">Intermediate</a>, or <a href="qvalidator.html#State-enum">Invalid</a>. The regexp can either be
supplied when the QRegExpValidator is constructed, or at a later
time.</p>
<p>When QRegExpValidator determines whether a string is <a href="qvalidator.html#State-enum">Acceptable</a> or not, the regexp is
treated as if it begins with the start of string assertion
(<b>^</b>) and ends with the end of string assertion (<b>$</b>);
the match is against the entire input string, or from the given
position if a start position greater than zero is given.</p>
<p>If a string is a prefix of an <a href="qvalidator.html#State-enum">Acceptable</a> string, it is
considered <a href="qvalidator.html#State-enum">Intermediate</a>.
For example, "" and "A" are <a href="qvalidator.html#State-enum">Intermediate</a> for the regexp
<b>[A-Z][0-9]</b> (whereas "<a href="index.html">_</a>" would be
<a href="qvalidator.html#State-enum">Invalid</a>).</p>
<p>For a brief introduction to Qt's regexp engine, see <a href="qregexp.html">QRegExp</a>.</p>
<p>Example of use:</p>
<pre class="cpp">
 <span class="comment">// regexp: optional '-' followed by between 1 and 3 digits</span>
 <span class="type"><a href="qregexp.html">QRegExp</a></span> rx(<span class="string">"-?\\d{1,3}"</span>);
 <span class="type"><a href="qvalidator.html">QValidator</a></span> <span class="operator">*</span>validator <span class="operator">=</span> <span class="keyword">new</span> <span class="type">QRegExpValidator</span>(rx<span class="operator">,</span> <span class="keyword">this</span>);

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

 s <span class="operator">=</span> <span class="string">"0"</span>;     v<span class="operator">.</span><a href="qregexpvalidator.html#validate">validate</a>(s<span class="operator">,</span> pos);    <span class="comment">// returns Invalid</span>
 s <span class="operator">=</span> <span class="string">"12345"</span>; v<span class="operator">.</span><a href="qregexpvalidator.html#validate">validate</a>(s<span class="operator">,</span> pos);    <span class="comment">// returns Invalid</span>
 s <span class="operator">=</span> <span class="string">"1"</span>;     v<span class="operator">.</span><a href="qregexpvalidator.html#validate">validate</a>(s<span class="operator">,</span> pos);    <span class="comment">// returns Acceptable</span>

 rx<span class="operator">.</span>setPattern(<span class="string">"\\S+"</span>);            <span class="comment">// one or more non-whitespace characters</span>
 v<span class="operator">.</span><a href="qregexpvalidator.html#regExp-prop">setRegExp</a>(rx);
 s <span class="operator">=</span> <span class="string">"myfile.txt"</span>;  v<span class="operator">.</span><a href="qregexpvalidator.html#validate">validate</a>(s<span class="operator">,</span> pos); <span class="comment">// Returns Acceptable</span>
 s <span class="operator">=</span> <span class="string">"my file.txt"</span>; v<span class="operator">.</span><a href="qregexpvalidator.html#validate">validate</a>(s<span class="operator">,</span> pos); <span class="comment">// Returns Invalid</span>

 <span class="comment">// A, B or C followed by exactly five digits followed by W, X, Y or Z</span>
 rx<span class="operator">.</span>setPattern(<span class="string">"[A-C]\\d{5}[W-Z]"</span>);
 v<span class="operator">.</span><a href="qregexpvalidator.html#regExp-prop">setRegExp</a>(rx);
 s <span class="operator">=</span> <span class="string">"a12345Z"</span>; v<span class="operator">.</span><a href="qregexpvalidator.html#validate">validate</a>(s<span class="operator">,</span> pos);        <span class="comment">// Returns Invalid</span>
 s <span class="operator">=</span> <span class="string">"A12345Z"</span>; v<span class="operator">.</span><a href="qregexpvalidator.html#validate">validate</a>(s<span class="operator">,</span> pos);        <span class="comment">// Returns Acceptable</span>
 s <span class="operator">=</span> <span class="string">"B12"</span>;     v<span class="operator">.</span><a href="qregexpvalidator.html#validate">validate</a>(s<span class="operator">,</span> pos);        <span class="comment">// Returns Intermediate</span>

 <span class="comment">// match most 'readme' files</span>
 rx<span class="operator">.</span>setPattern(<span class="string">"read\\S?me(\.(txt|asc|1st))?"</span>);
 rx<span class="operator">.</span>setCaseSensitive(<span class="keyword">false</span>);
 v<span class="operator">.</span><a href="qregexpvalidator.html#regExp-prop">setRegExp</a>(rx);
 s <span class="operator">=</span> <span class="string">"readme"</span>;      v<span class="operator">.</span><a href="qregexpvalidator.html#validate">validate</a>(s<span class="operator">,</span> pos); <span class="comment">// Returns Acceptable</span>
 s <span class="operator">=</span> <span class="string">"README.1ST"</span>;  v<span class="operator">.</span><a href="qregexpvalidator.html#validate">validate</a>(s<span class="operator">,</span> pos); <span class="comment">// Returns Acceptable</span>
 s <span class="operator">=</span> <span class="string">"read me.txt"</span>; v<span class="operator">.</span><a href="qregexpvalidator.html#validate">validate</a>(s<span class="operator">,</span> pos); <span class="comment">// Returns Invalid</span>
 s <span class="operator">=</span> <span class="string">"readm"</span>;       v<span class="operator">.</span><a href="qregexpvalidator.html#validate">validate</a>(s<span class="operator">,</span> pos); <span class="comment">// Returns Intermediate</span>
</pre><hr /><h2>Method Documentation</h2><h3 class="fn"><a name="QRegExpValidator" />QRegExpValidator.__init__ (<i>self</i>, <a href="qobject.html">QObject</a>&#160;<i>parent</i>&#160;=&#160;None)</h3><p>The <i>parent</i> argument, if not None, causes <i>self</i> to be owned by Qt instead of PyQt.</p><p>Constructs a validator with a <i>parent</i> object that accepts
any string (including an empty one) as valid.</p>


<h3 class="fn"><a name="QRegExpValidator-2" />QRegExpValidator.__init__ (<i>self</i>, <a href="qregexp.html">QRegExp</a>&#160;<i>rx</i>, <a href="qobject.html">QObject</a>&#160;<i>parent</i>&#160;=&#160;None)</h3><p>The <i>parent</i> argument, if not None, causes <i>self</i> to be owned by Qt instead of PyQt.</p><p>Constructs a validator with a <i>parent</i> object that accepts
all strings that match the regular expression <i>rx</i>.</p>
<p>The match is made against the entire string; e.g. if the regexp
is <b>[A-Fa-f0-9]+</b> it will be treated as
<b>^[A-Fa-f0-9]+$</b>.</p>


<h3 class="fn"><a name="regExp" /><a href="qregexp.html">QRegExp</a> QRegExpValidator.regExp (<i>self</i>)</h3><h3 class="fn"><a name="setRegExp" />QRegExpValidator.setRegExp (<i>self</i>, <a href="qregexp.html">QRegExp</a>&#160;<i>rx</i>)</h3><h3 class="fn"><a name="validate" />(<a href="qvalidator.html#State-enum">QValidator.State</a>, QString&#160;<i>input</i>, int&#160;<i>pos</i>) QRegExpValidator.validate (<i>self</i>, QString&#160;<i>input</i>, int&#160;<i>pos</i>)</h3><p>Reimplemented from <a href="qvalidator.html#validate">QValidator.validate</a>().</p>
<p>Returns <a href="qvalidator.html#State-enum">Acceptable</a> if
<i>input</i> is matched by the regular expression for this
validator, <a href="qvalidator.html#State-enum">Intermediate</a> if
it has matched partially (i.e. could be a valid match if additional
valid characters are added), and <a href="qvalidator.html#State-enum">Invalid</a> if <i>input</i> is not
matched.</p>
<p>The <i>pos</i> parameter is set to the length of the
<i>input</i> parameter.</p>
<p>For example, if the regular expression is <b>\w\d\d</b>
(word-character, digit, digit) then "A57" is <a href="qvalidator.html#State-enum">Acceptable</a>, "E5" is <a href="qvalidator.html#State-enum">Intermediate</a>, and "+9" is <a href="qvalidator.html#State-enum">Invalid</a>.</p>
<p><b>See also</b> <a href="qregexp.html#exactMatch">QRegExp.exactMatch</a>().</p>
<h3 class="fn"><a name="validate-2" />(<a href="qvalidator.html#State-enum">QValidator.State</a>, int&#160;<i>pos</i>) QRegExpValidator.validate (<i>self</i>, QString&#160;<i>input</i>, int&#160;<i>pos</i>)</h3><address><hr /><div align="center"><table border="0" cellspacing="0" width="100%"><tr class="address"><td align="left" width="25%">PyQt&#160;4.10.3 for X11</td><td align="center" width="50%">Copyright &#169; <a href="http://www.riverbankcomputing.com">Riverbank&#160;Computing&#160;Ltd</a> and <a href="http://www.qtsoftware.com">Nokia</a> 2012</td><td align="right" width="25%">Qt&#160;4.8.5</td></tr></table></div></address></body></html>