File: qlatin1string.html

package info (click to toggle)
python-qt4 4.0.1-5
  • links: PTS
  • area: main
  • in suites: etch, etch-m68k
  • size: 18,632 kB
  • ctags: 2,639
  • sloc: python: 29,409; sh: 5,646; cpp: 3,168; xml: 149; makefile: 109
file content (45 lines) | stat: -rw-r--r-- 6,849 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
<?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>QLatin1String 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="../pyqt4ref.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">QLatin1String Class Reference<br /><sup><sup>[<a href="qtcore.html">QtCore</a> module]</sup></sup></h1><p>The QLatin1String class provides a thin wrapper around an ASCII/Latin-1 encoded string literal. <a href="#details">More...</a></p>
<h3>Methods</h3><ul><li><div class="fn" /><b><a href="qlatin1string.html#QLatin1String">__init__</a></b> (<i>self</i>, str&#160;<i>s</i>)</li><li><div class="fn" /><b><a href="qlatin1string.html#QLatin1String-2">__init__</a></b> (<i>self</i>, QLatin1String)</li><li><div class="fn" />str <b><a href="qlatin1string.html#latin1">latin1</a></b> (<i>self</i>)</li></ul><h3>Special Methods</h3><ul><li><div class="fn" />bool <b><a href="qlatin1string.html#__eq__">__eq__</a></b> (<i>self</i>, QString&#160;<i>s</i>)</li><li><div class="fn" />bool <b><a href="qlatin1string.html#__ge__">__ge__</a></b> (<i>self</i>, QString&#160;<i>s</i>)</li><li><div class="fn" />bool <b><a href="qlatin1string.html#__gt__">__gt__</a></b> (<i>self</i>, QString&#160;<i>s</i>)</li><li><div class="fn" />bool <b><a href="qlatin1string.html#__le__">__le__</a></b> (<i>self</i>, QString&#160;<i>s</i>)</li><li><div class="fn" />bool <b><a href="qlatin1string.html#__lt__">__lt__</a></b> (<i>self</i>, QString&#160;<i>s</i>)</li><li><div class="fn" />bool <b><a href="qlatin1string.html#__ne__">__ne__</a></b> (<i>self</i>, QString&#160;<i>s</i>)</li></ul><a name="details" /><hr /><h2>Detailed Description</h2><p>The QLatin1String class provides a thin wrapper around an ASCII/Latin-1 encoded string literal.</p>
<p>Many of <a href="qstring.html">QString</a>'s member functions are overloaded to accept <tt>const char *</tt> instead of <a href="qstring.html">QString</a>. This includes the copy constructor, the assignment operator, the comparison operators, and various other functions such as <a href="qstring.html#insert">insert()</a>, <a href="qstring.html#replace">replace()</a>, and <a href="qstring.html#indexOf">indexOf()</a>. These functions are usually optimized to avoid constructing a <a href="qstring.html">QString</a> object for the <tt>const char *</tt> data. For example, assuming <tt>str</tt> is a <a href="qstring.html">QString</a>,</p>
<pre>
    if (str == "auto" || str == "extern"
            || str == "static" || str == "register") {
        ...
    }
</pre>
<p>is much faster than</p>
<pre>
    if (str == QString("auto") || str == QString("extern")
            || str == QString("static") || str == QString("register")) {
        ...
    }
</pre>
<p>because it doesn't construct four temporary <a href="qstring.html">QString</a> objects and make a deep copy of the character data.</p>
<p>Applications that define <tt>QT_NO_CAST_FROM_ASCII</tt> (as explained in the <a href="qstring.html">QString</a> documentation) don't have access to <a href="qstring.html">QString</a>'s <tt>const char *</tt> API. To provide an efficient way of specifying constant Latin-1 strings, Qt provides the QLatin1String, which is just a very thin wrapper around a <tt>const char *</tt>. Using QLatin1String, the example code above becomes</p>
<pre>
    if (str == QLatin1String("auto")
            || str == QLatin1String("extern")
            || str == QLatin1String("static")
            || str == QLatin1String("register") {
        ...
    }
</pre>
<p>This is a bit longer to type, but it provides exactly the same benefits as the first version of the code, and is faster than converting the Latin-1 strings using <a href="qstring.html#fromLatin1">QString.fromLatin1</a>().</p>
<p>Thanks to the <a href="qstring.html">QString</a>(const QLatin1String &amp;) constructor, QLatin1String can be used everywhere a <a href="qstring.html">QString</a> is expected. For example:</p>
<pre>
    QLabel *label = new QLabel(QLatin1String("MOD"), this);
</pre>
<p>See also <a href="qstring.html">QString</a> and <a href="qlatin1char.html">QLatin1Char</a>.</p>
<hr /><h2>Method Documentation</h2><h3 class="fn"><a name="QLatin1String" />QLatin1String.__init__ (<i>self</i>, str&#160;<i>s</i>)</h3><p>Constructs a <a href="qlatin1string.html">QLatin1String</a> object that stores <i>str</i>.</p>
<p>The string data is <i>not</i> copied. The caller must be able to guarantee that <i>str</i> will not be deleted or modified as long as the <a href="qlatin1string.html">QLatin1String</a> object exists.</p>
<p>See also <a href="qlatin1string.html#latin1">latin1</a>().</p>
<h3 class="fn"><a name="QLatin1String-2" />QLatin1String.__init__ (<i>self</i>, <a href="qlatin1string.html">QLatin1String</a>)</h3><h3 class="fn"><a name="latin1" />str QLatin1String.latin1 (<i>self</i>)</h3><p>Returns the Latin-1 string stored in this object.</p>
<h3 class="fn"><a name="__eq__" />bool QLatin1String.__eq__ (<i>self</i>, <a href="qstring.html">QString</a>&#160;<i>s</i>)</h3><h3 class="fn"><a name="__ge__" />bool QLatin1String.__ge__ (<i>self</i>, <a href="qstring.html">QString</a>&#160;<i>s</i>)</h3><h3 class="fn"><a name="__gt__" />bool QLatin1String.__gt__ (<i>self</i>, <a href="qstring.html">QString</a>&#160;<i>s</i>)</h3><h3 class="fn"><a name="__le__" />bool QLatin1String.__le__ (<i>self</i>, <a href="qstring.html">QString</a>&#160;<i>s</i>)</h3><h3 class="fn"><a name="__lt__" />bool QLatin1String.__lt__ (<i>self</i>, <a href="qstring.html">QString</a>&#160;<i>s</i>)</h3><h3 class="fn"><a name="__ne__" />bool QLatin1String.__ne__ (<i>self</i>, <a href="qstring.html">QString</a>&#160;<i>s</i>)</h3><address><hr /><div align="center"><table border="0" cellspacing="0" width="100%"><tr class="address"><td width="25%">PyQt&#160;4.0.1 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.trolltech.com">Trolltech&#160;AS</a> 2006</td><td align="right" width="25%">Qt&#160;4.1.4</td></tr></table></div></address></body></html>