Sophie

Sophie

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

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>QStaticText 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">QStaticText Class Reference<br /><sup><sup>[<a href="qtgui.html">QtGui</a> module]</sup></sup></h1><p>The QStaticText class enables optimized drawing of text when the
text and its layout is updated rarely. <a href="#details">More...</a></p>

<h3>Types</h3><ul><li><div class="fn" />enum <b><a href="qstatictext.html#PerformanceHint-enum">PerformanceHint</a></b> { ModerateCaching, AggressiveCaching }</li></ul><h3>Methods</h3><ul><li><div class="fn" /><b><a href="qstatictext.html#QStaticText">__init__</a></b> (<i>self</i>)</li><li><div class="fn" /><b><a href="qstatictext.html#QStaticText-2">__init__</a></b> (<i>self</i>, QString&#160;<i>text</i>)</li><li><div class="fn" /><b><a href="qstatictext.html#QStaticText-3">__init__</a></b> (<i>self</i>, QStaticText&#160;<i>other</i>)</li><li><div class="fn" />PerformanceHint <b><a href="qstatictext.html#performanceHint">performanceHint</a></b> (<i>self</i>)</li><li><div class="fn" /><b><a href="qstatictext.html#prepare">prepare</a></b> (<i>self</i>, QTransform&#160;<i>matrix</i>&#160;=&#160;QTransform(), QFont&#160;<i>font</i>&#160;=&#160;QFont())</li><li><div class="fn" /><b><a href="qstatictext.html#setPerformanceHint">setPerformanceHint</a></b> (<i>self</i>, PerformanceHint&#160;<i>performanceHint</i>)</li><li><div class="fn" /><b><a href="qstatictext.html#setText">setText</a></b> (<i>self</i>, QString&#160;<i>text</i>)</li><li><div class="fn" /><b><a href="qstatictext.html#setTextFormat">setTextFormat</a></b> (<i>self</i>, Qt.TextFormat&#160;<i>textFormat</i>)</li><li><div class="fn" /><b><a href="qstatictext.html#setTextOption">setTextOption</a></b> (<i>self</i>, QTextOption&#160;<i>textOption</i>)</li><li><div class="fn" /><b><a href="qstatictext.html#setTextWidth">setTextWidth</a></b> (<i>self</i>, float&#160;<i>textWidth</i>)</li><li><div class="fn" />QSizeF <b><a href="qstatictext.html#size">size</a></b> (<i>self</i>)</li><li><div class="fn" />QString <b><a href="qstatictext.html#text">text</a></b> (<i>self</i>)</li><li><div class="fn" />Qt.TextFormat <b><a href="qstatictext.html#textFormat">textFormat</a></b> (<i>self</i>)</li><li><div class="fn" />QTextOption <b><a href="qstatictext.html#textOption">textOption</a></b> (<i>self</i>)</li><li><div class="fn" />float <b><a href="qstatictext.html#textWidth">textWidth</a></b> (<i>self</i>)</li></ul><h3>Special Methods</h3><ul><li><div class="fn" />bool <b><a href="qstatictext.html#__eq__">__eq__</a></b> (<i>self</i>, QStaticText)</li><li><div class="fn" />bool <b><a href="qstatictext.html#__ne__">__ne__</a></b> (<i>self</i>, QStaticText)</li></ul><a name="details" /><hr /><h2>Detailed Description</h2><p>The QStaticText class enables optimized drawing of text when the
text and its layout is updated rarely.</p>
<p>QStaticText provides a way to cache layout data for a block of
text so that it can be drawn more efficiently than by using
<a href="qpainter.html#drawText">QPainter.drawText</a>() in which
the layout information is recalculated with every call.</p>
<p>The class primarily provides an optimization for cases where the
text, its font and the transformations on the painter are static
over several paint events. If the text or its layout is changed for
every iteration, <a href="qpainter.html#drawText">QPainter.drawText</a>() is the more
efficient alternative, since the static text's layout would have to
be recalculated to take the new state into consideration.</p>
<p>Translating the painter will not cause the layout of the text to
be recalculated, but will cause a very small performance impact on
drawStaticText(). Altering any other parts of the painter's
transformation or the painter's font will cause the layout of the
static text to be recalculated. This should be avoided as often as
possible to maximize the performance benefit of using
QStaticText.</p>
<p>In addition, only affine transformations are supported by
drawStaticText(). Calling drawStaticText() on a projected painter
will perform slightly worse than using the regular drawText() call,
so this should be avoided.</p>
<pre class="cpp">
 <span class="keyword">class</span> MyWidget: <span class="keyword">public</span> <span class="type"><a href="qwidget.html">QWidget</a></span>
 {
 <span class="keyword">public</span>:
     MyWidget(<span class="type"><a href="qwidget.html">QWidget</a></span> <span class="operator">*</span>parent <span class="operator">=</span> <span class="number">0</span>) : <span class="type"><a href="qwidget.html">QWidget</a></span>(parent)<span class="operator">,</span> m_staticText(<span class="string">"This is static text"</span>)

 <span class="keyword">protected</span>:
     <span class="type">void</span> paintEvent(<span class="type"><a href="qpaintevent.html">QPaintEvent</a></span> <span class="operator">*</span>)
     {
         <span class="type"><a href="qpainter.html">QPainter</a></span> painter(<span class="keyword">this</span>);
         painter<span class="operator">.</span>drawStaticText(<span class="number">0</span><span class="operator">,</span> <span class="number">0</span><span class="operator">,</span> m_staticText);
     }

 <span class="keyword">private</span>:
     <span class="type">QStaticText</span> m_staticText;
 };
</pre>
<p>The QStaticText class can be used to mimic the behavior of
<a href="qpainter.html#drawText">QPainter.drawText</a>() to a
specific point with no boundaries, and also when <a href="qpainter.html#drawText">QPainter.drawText</a>() is called with a
bounding rectangle.</p>
<p>If a bounding rectangle is not required, create a QStaticText
object without setting a preferred text width. The text will then
occupy a single line.</p>
<p>If you set a text width on the QStaticText object, this will
bound the text. The text will be formatted so that no line exceeds
the given width. The text width set for QStaticText will not
automatically be used for clipping. To achieve clipping in addition
to line breaks, use <a href="qpainter.html#setClipRect">QPainter.setClipRect</a>(). The
position of the text is decided by the argument passed to <a href="qpainter.html#drawStaticText">QPainter.drawStaticText</a>() and
can change from call to call with a minimal impact on
performance.</p>
<p>For extra convenience, it is possible to apply formatting to the
text using the HTML subset supported by <a href="qtextdocument.html">QTextDocument</a>. QStaticText will attempt to
guess the format of the input text using <a href="qt.html#mightBeRichText">Qt.mightBeRichText</a>(), and interpret
it as rich text if this function returns true. To force QStaticText
to display its contents as either plain text or rich text, use the
function <a href="qstatictext.html#setTextFormat">QStaticText.setTextFormat</a>()
and pass in, respectively, <a href="qt.html#TextFormat-enum">Qt.PlainText</a> and <a href="qt.html#TextFormat-enum">Qt.RichText</a>.</p>
<p>QStaticText can only represent text, so only HTML tags which
alter the layout or appearance of the text will be respected.
Adding an image to the input HTML, for instance, will cause the
image to be included as part of the layout, affecting the positions
of the text glyphs, but it will not be displayed. The result will
be an empty area the size of the image in the output. Similarly,
using tables will cause the text to be laid out in table format,
but the borders will not be drawn.</p>
<p>If it's the first time the static text is drawn, or if the
static text, or the painter's font has been altered since the last
time it was drawn, the text's layout has to be recalculated. On
some paint engines, changing the matrix of the painter will also
cause the layout to be recalculated. In particular, this will
happen for any engine except for the OpenGL2 paint engine.
Recalculating the layout will impose an overhead on the <a href="qpainter.html#drawStaticText">QPainter.drawStaticText</a>() call
where it occurs. To avoid this overhead in the paint event, you can
call <a href="qstatictext.html#prepare">prepare</a>() ahead of time
to ensure that the layout is calculated.</p>
<hr /><h2>Type Documentation</h2><h3 class="fn"><a name="PerformanceHint-enum" />QStaticText.PerformanceHint</h3><p>This enum the different performance hints that can be set on the
<a href="qstatictext.html">QStaticText</a>. These hints can be used
to indicate that the <a href="qstatictext.html">QStaticText</a>
should use additional caches, if possible, to improve performance
at the expense of memory. In particular, setting the performance
hint AggressiveCaching on the <a href="qstatictext.html">QStaticText</a> will improve performance when
using the OpenGL graphics system or when drawing to a <a href="qglwidget.html">QGLWidget</a>.</p>
<table class="valuelist">
<tr class="odd" valign="top">
<th class="tblConst">Constant</th>
<th class="tblval">Value</th>
<th class="tbldscr">Description</th>
</tr>
<tr>
<td class="topAlign"><tt>QStaticText.ModerateCaching</tt></td>
<td class="topAlign"><tt>0</tt></td>
<td class="topAlign">Do basic caching for high performance at a low
memory cost.</td>
</tr>
<tr>
<td class="topAlign"><tt>QStaticText.AggressiveCaching</tt></td>
<td class="topAlign"><tt>1</tt></td>
<td class="topAlign">Use additional caching when available. This
may improve performance at a higher memory cost.</td>
</tr>
</table>
<hr /><h2>Method Documentation</h2><h3 class="fn"><a name="QStaticText" />QStaticText.__init__ (<i>self</i>)</h3><p>Constructs an empty <a href="qstatictext.html">QStaticText</a></p>


<h3 class="fn"><a name="QStaticText-2" />QStaticText.__init__ (<i>self</i>, QString&#160;<i>text</i>)</h3><p>Constructs a <a href="qstatictext.html">QStaticText</a> object
with the given <i>text</i>.</p>


<h3 class="fn"><a name="QStaticText-3" />QStaticText.__init__ (<i>self</i>, <a href="qstatictext.html">QStaticText</a>&#160;<i>other</i>)</h3><p>Constructs a <a href="qstatictext.html">QStaticText</a> object
which is a copy of <i>other</i>.</p>


<h3 class="fn"><a name="performanceHint" /><a href="qstatictext.html#PerformanceHint-enum">PerformanceHint</a> QStaticText.performanceHint (<i>self</i>)</h3><p>Returns which performance hint is set for the <a href="qstatictext.html">QStaticText</a>.</p>
<p><b>See also</b> <a href="qstatictext.html#setPerformanceHint">setPerformanceHint</a>().</p>


<h3 class="fn"><a name="prepare" />QStaticText.prepare (<i>self</i>, <a href="qtransform.html">QTransform</a>&#160;<i>matrix</i>&#160;=&#160;QTransform(), <a href="qfont.html">QFont</a>&#160;<i>font</i>&#160;=&#160;QFont())</h3><p>Prepares the <a href="qstatictext.html">QStaticText</a> object
for being painted with the given <i>matrix</i> and the given
<i>font</i> to avoid overhead when the actual drawStaticText() call
is made.</p>
<p>When drawStaticText() is called, the layout of the <a href="qstatictext.html">QStaticText</a> will be recalculated if any part
of the <a href="qstatictext.html">QStaticText</a> object has
changed since the last time it was drawn. It will also be
recalculated if the painter's font is not the same as when the
<a href="qstatictext.html">QStaticText</a> was last drawn, or, on
any other paint engine than the OpenGL2 engine, if the painter's
matrix has been altered since the static text was last drawn.</p>
<p>To avoid the overhead of creating the layout the first time you
draw the <a href="qstatictext.html">QStaticText</a> after making
changes, you can use the prepare() function and pass in the
<i>matrix</i> and <i>font</i> you expect to use when drawing the
text.</p>
<p><b>See also</b> <a href="qpainter.html#setFont">QPainter.setFont</a>() and <a class="obsolete" href="qpainter-obsolete.html#setMatrix">QPainter.setMatrix</a>().</p>


<h3 class="fn"><a name="setPerformanceHint" />QStaticText.setPerformanceHint (<i>self</i>, <a href="qstatictext.html#PerformanceHint-enum">PerformanceHint</a>&#160;<i>performanceHint</i>)</h3><p>Sets the performance hint of the <a href="qstatictext.html">QStaticText</a> according to the
<i>performanceHint</i> provided. The <i>performanceHint</i> is used
to customize how much caching is done internally to improve
performance.</p>
<p>The default is <a href="qstatictext.html#PerformanceHint-enum">QStaticText.ModerateCaching</a>.</p>
<p><b>Note:</b> This function will cause the layout of the text to
require recalculation.</p>
<p><b>See also</b> <a href="qstatictext.html#performanceHint">performanceHint</a>().</p>


<h3 class="fn"><a name="setText" />QStaticText.setText (<i>self</i>, QString&#160;<i>text</i>)</h3><p>Sets the text of the <a href="qstatictext.html">QStaticText</a>
to <i>text</i>.</p>
<p><b>Note:</b> This function will cause the layout of the text to
require recalculation.</p>
<p><b>See also</b> <a href="qstatictext.html#text">text</a>().</p>


<h3 class="fn"><a name="setTextFormat" />QStaticText.setTextFormat (<i>self</i>, <a href="qt.html#TextFormat-enum">Qt.TextFormat</a>&#160;<i>textFormat</i>)</h3><p>Sets the text format of the <a href="qstatictext.html">QStaticText</a> to <i>textFormat</i>. If
<i>textFormat</i> is set to <a href="qt.html#TextFormat-enum">Qt.AutoText</a> (the default), the
format of the text will try to be determined using the function
<a href="qt.html#mightBeRichText">Qt.mightBeRichText</a>(). If the
text format is <a href="qt.html#TextFormat-enum">Qt.PlainText</a>,
then the text will be displayed as is, whereas it will be
interpreted as HTML if the format is <a href="qt.html#TextFormat-enum">Qt.RichText</a>. HTML tags that alter
the font of the text, its color, or its layout are supported by
<a href="qstatictext.html">QStaticText</a>.</p>
<p><b>Note:</b> This function will cause the layout of the text to
require recalculation.</p>
<p><b>See also</b> <a href="qstatictext.html#textFormat">textFormat</a>(), <a href="qstatictext.html#setText">setText</a>(), and <a href="qstatictext.html#text">text</a>().</p>


<h3 class="fn"><a name="setTextOption" />QStaticText.setTextOption (<i>self</i>, <a href="qtextoption.html">QTextOption</a>&#160;<i>textOption</i>)</h3><p>Sets the text option structure that controls the layout process
to the given <i>textOption</i>.</p>
<p><b>See also</b> <a href="qstatictext.html#textOption">textOption</a>().</p>


<h3 class="fn"><a name="setTextWidth" />QStaticText.setTextWidth (<i>self</i>, float&#160;<i>textWidth</i>)</h3><p>Sets the preferred width for this <a href="qstatictext.html">QStaticText</a>. If the text is wider than the
specified width, it will be broken into multiple lines and grow
vertically. If the text cannot be split into multiple lines, it
will be larger than the specified <i>textWidth</i>.</p>
<p>Setting the preferred text width to a negative number will cause
the text to be unbounded.</p>
<p>Use <a href="qstatictext.html#size">size</a>() to get the actual
size of the text.</p>
<p><b>Note:</b> This function will cause the layout of the text to
require recalculation.</p>
<p><b>See also</b> <a href="qstatictext.html#textWidth">textWidth</a>() and <a href="qstatictext.html#size">size</a>().</p>


<h3 class="fn"><a name="size" /><a href="qsizef.html">QSizeF</a> QStaticText.size (<i>self</i>)</h3><p>Returns the size of the bounding rect for this <a href="qstatictext.html">QStaticText</a>.</p>
<p><b>See also</b> <a href="qstatictext.html#textWidth">textWidth</a>().</p>


<h3 class="fn"><a name="text" />QString QStaticText.text (<i>self</i>)</h3><p>Returns the text of the <a href="qstatictext.html">QStaticText</a>.</p>
<p><b>See also</b> <a href="qstatictext.html#setText">setText</a>().</p>


<h3 class="fn"><a name="textFormat" /><a href="qt.html#TextFormat-enum">Qt.TextFormat</a> QStaticText.textFormat (<i>self</i>)</h3><p>Returns the text format of the <a href="qstatictext.html">QStaticText</a>.</p>
<p><b>See also</b> <a href="qstatictext.html#setTextFormat">setTextFormat</a>(), <a href="qstatictext.html#setText">setText</a>(), and <a href="qstatictext.html#text">text</a>().</p>


<h3 class="fn"><a name="textOption" /><a href="qtextoption.html">QTextOption</a> QStaticText.textOption (<i>self</i>)</h3><p>Returns the current text option used to control the layout
process.</p>
<p><b>See also</b> <a href="qstatictext.html#setTextOption">setTextOption</a>().</p>


<h3 class="fn"><a name="textWidth" />float QStaticText.textWidth (<i>self</i>)</h3><p>Returns the preferred width for this <a href="qstatictext.html">QStaticText</a>.</p>
<p><b>See also</b> <a href="qstatictext.html#setTextWidth">setTextWidth</a>().</p>


<h3 class="fn"><a name="__eq__" />bool QStaticText.__eq__ (<i>self</i>, <a href="qstatictext.html">QStaticText</a>)</h3><h3 class="fn"><a name="__ne__" />bool QStaticText.__ne__ (<i>self</i>, <a href="qstatictext.html">QStaticText</a>)</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>