~ubuntu-branches/ubuntu/precise/python-qt4/precise-proposed

« back to all changes in this revision

Viewing changes to doc/html/qstatictext.html

  • Committer: Bazaar Package Importer
  • Author(s): Jonathan Riddell, Jonathan Riddell
  • Date: 2010-11-08 16:13:33 UTC
  • mfrom: (1.5.5 upstream)
  • Revision ID: james.westby@ubuntu.com-20101108161333-0nec4wu0nz3wpf9r
Tags: 4.8.1-0ubuntu1
[ Jonathan Riddell ]
* New upstream release
* Build against python-sip-dev 4.11.2
* Remove kubuntu_02_fix-scpk-and-flag-issue.diff merged upstream
* Install __init__.py into /usr/lib/python3.2/dist-packages/PyQt4,
  fixes Python 3 support
* Add QtDeclarative to python-qt4
* Add kubuntu_03_uiparser.diff from upstream

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
<?xml version="1.0" encoding="iso-8859-1"?>
 
2
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "DTD/xhtml1-strict.dtd">
 
3
<html><head><title>QStaticText Class Reference</title><style>h3.fn,span.fn { margin-left: 1cm; text-indent: -1cm }
 
4
a:link { color: #004faf; text-decoration: none }
 
5
a:visited { color: #672967; text-decoration: none }
 
6
td.postheader { font-family: sans-serif }
 
7
tr.address { font-family: sans-serif }
 
8
body { background: #ffffff; color: black; }
 
9
</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">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
 
10
text and its layout is updated rarely. <a href="#details">More...</a></p>
 
11
 
 
12
<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
 
13
text and its layout is updated rarely.</p>
 
14
<p>QStaticText provides a way to cache layout data for a block of
 
15
text so that it can be drawn more efficiently than by using
 
16
<a href="qpainter.html#drawText">QPainter.drawText</a>() in which
 
17
the layout information is recalculated with every call.</p>
 
18
<p>The class primarily provides an optimization for cases where the
 
19
text, its font and the transformations on the painter are static
 
20
over several paint events. If the text or its layout is changed for
 
21
every iteration, <a href="qpainter.html#drawText">QPainter.drawText</a>() is the more
 
22
efficient alternative, since the static text's layout would have to
 
23
be recalculated to take the new state into consideration.</p>
 
24
<p>Translating the painter will not cause the layout of the text to
 
25
be recalculated, but will cause a very small performance impact on
 
26
drawStaticText(). Altering any other parts of the painter's
 
27
transformation or the painter's font will cause the layout of the
 
28
static text to be recalculated. This should be avoided as often as
 
29
possible to maximize the performance benefit of using
 
30
QStaticText.</p>
 
31
<p>In addition, only affine transformations are supported by
 
32
drawStaticText(). Calling drawStaticText() on a projected painter
 
33
will perform slightly worse than using the regular drawText() call,
 
34
so this should be avoided.</p>
 
35
<pre class="highlightedCode brush: cpp">
 
36
 class MyWidget: public QWidget
 
37
 {
 
38
 public:
 
39
     MyWidget(QWidget *parent = 0) : QWidget(parent), m_staticText("This is static text")
 
40
 
 
41
 protected:
 
42
     void paintEvent(QPaintEvent *)
 
43
     {
 
44
         QPainter painter(this);
 
45
         painter.drawStaticText(0, 0, m_staticText);
 
46
     }
 
47
 
 
48
 private:
 
49
     QStaticText m_staticText;
 
50
 };
 
51
</pre>
 
52
<p>The QStaticText class can be used to mimic the behavior of
 
53
<a href="qpainter.html#drawText">QPainter.drawText</a>() to a
 
54
specific point with no boundaries, and also when <a href="qpainter.html#drawText">QPainter.drawText</a>() is called with a
 
55
bounding rectangle.</p>
 
56
<p>If a bounding rectangle is not required, create a QStaticText
 
57
object without setting a preferred text width. The text will then
 
58
occupy a single line.</p>
 
59
<p>If you set a text width on the QStaticText object, this will
 
60
bound the text. The text will be formatted so that no line exceeds
 
61
the given width. The text width set for QStaticText will not
 
62
automatically be used for clipping. To achieve clipping in addition
 
63
to line breaks, use <a href="qpainter.html#setClipRect">QPainter.setClipRect</a>(). The
 
64
position of the text is decided by the argument passed to <a href="qpainter.html#drawStaticText">QPainter.drawStaticText</a>() and
 
65
can change from call to call with a minimal impact on
 
66
performance.</p>
 
67
<p>QStaticText will attempt to guess the format of the input text
 
68
using <a href="qt.html#mightBeRichText">Qt.mightBeRichText</a>().
 
69
To force QStaticText to display its contents as either plain text
 
70
or rich text, use the function <a href="qstatictext.html#setTextFormat">QStaticText.setTextFormat</a>()
 
71
and pass in, respectively, <a href="qt.html#TextFormat-enum">Qt.PlainText</a> and <a href="qt.html#TextFormat-enum">Qt.RichText</a>.</p>
 
72
<p>If it's the first time the static text is drawn, or if the
 
73
static text, or the painter's font has been altered since the last
 
74
time it was drawn, the text's layout has to be recalculated. On
 
75
some paint engines, changing the matrix of the painter will also
 
76
cause the layout to be recalculated. In particular, this will
 
77
happen for any engine except for the OpenGL2 paint engine.
 
78
Recalculating the layout will impose an overhead on the <a href="qpainter.html#drawStaticText">QPainter.drawStaticText</a>() call
 
79
where it occurs. To avoid this overhead in the paint event, you can
 
80
call <a href="qstatictext.html#prepare">prepare</a>() ahead of time
 
81
to ensure that the layout is calculated.</p>
 
82
<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
 
83
<a href="qstatictext.html">QStaticText</a>. These hints can be used
 
84
to indicate that the <a href="qstatictext.html">QStaticText</a>
 
85
should use additional caches, if possible, to improve performance
 
86
at the expense of memory. In particular, setting the performance
 
87
hint AggressiveCaching on the <a href="qstatictext.html">QStaticText</a> will improve performance when
 
88
using the OpenGL graphics system or when drawing to a <a href="qglwidget.html">QGLWidget</a>.</p>
 
89
<table class="valuelist">
 
90
<tr class="odd">
 
91
<td />
 
92
</tr>
 
93
<tr>
 
94
<th class="tblConst">Constant</th>
 
95
<th class="tblval">Value</th>
 
96
<th class="tbldscr">Description</th>
 
97
</tr>
 
98
<tr>
 
99
<td class="topAlign"><tt>QStaticText.ModerateCaching</tt></td>
 
100
<td class=" topAlign"><tt>0</tt></td>
 
101
<td class="topAlign">Do basic caching for high performance at a low
 
102
memory cost.</td>
 
103
</tr>
 
104
<tr>
 
105
<td class="topAlign"><tt>QStaticText.AggressiveCaching</tt></td>
 
106
<td class=" topAlign"><tt>1</tt></td>
 
107
<td class="topAlign">Use additional caching when available. This
 
108
may improve performance at a higher memory cost.</td>
 
109
</tr>
 
110
</table>
 
111
<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>
 
112
 
 
113
 
 
114
<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
 
115
with the given <i>text</i>.</p>
 
116
 
 
117
 
 
118
<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
 
119
which is a copy of <i>other</i>.</p>
 
120
 
 
121
 
 
122
<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>
 
123
<p>See also <a href="qstatictext.html#setPerformanceHint">setPerformanceHint</a>().</p>
 
124
 
 
125
 
 
126
<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
 
127
for being painted with the given <i>matrix</i> and the given
 
128
<i>font</i> to avoid overhead when the actual drawStaticText() call
 
129
is made.</p>
 
130
<p>When drawStaticText() is called, the layout of the <a href="qstatictext.html">QStaticText</a> will be recalculated if any part
 
131
of the <a href="qstatictext.html">QStaticText</a> object has
 
132
changed since the last time it was drawn. It will also be
 
133
recalculated if the painter's font is not the same as when the
 
134
<a href="qstatictext.html">QStaticText</a> was last drawn, or, on
 
135
any other paint engine than the OpenGL2 engine, if the painter's
 
136
matrix has been altered since the static text was last drawn.</p>
 
137
<p>To avoid the overhead of creating the layout the first time you
 
138
draw the <a href="qstatictext.html">QStaticText</a> after making
 
139
changes, you can use the prepare() function and pass in the
 
140
<i>matrix</i> and <i>font</i> you expect to use when drawing the
 
141
text.</p>
 
142
<p>See also <a href="qpainter.html#setFont">QPainter.setFont</a>()
 
143
and <a class="obsolete" href="qpainter.html#setMatrix">QPainter.setMatrix</a>().</p>
 
144
 
 
145
 
 
146
<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
 
147
<i>performanceHint</i> provided. The <i>performanceHint</i> is used
 
148
to customize how much caching is done internally to improve
 
149
performance.</p>
 
150
<p>The default is <a href="qstatictext.html#PerformanceHint-enum">QStaticText.ModerateCaching</a>.</p>
 
151
<p><b>Note:</b> This function will cause the layout of the text to
 
152
require recalculation.</p>
 
153
<p>See also <a href="qstatictext.html#performanceHint">performanceHint</a>().</p>
 
154
 
 
155
 
 
156
<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>
 
157
to <i>text</i>.</p>
 
158
<p><b>Note:</b> This function will cause the layout of the text to
 
159
require recalculation.</p>
 
160
<p>See also <a href="qstatictext.html#text">text</a>().</p>
 
161
 
 
162
 
 
163
<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
 
164
<i>textFormat</i> is set to <a href="qt.html#TextFormat-enum">Qt.AutoText</a> (the default), the
 
165
format of the text will try to be determined using the function
 
166
<a href="qt.html#mightBeRichText">Qt.mightBeRichText</a>(). If the
 
167
text format is <a href="qt.html#TextFormat-enum">Qt.PlainText</a>,
 
168
then the text will be displayed as is, whereas it will be
 
169
interpreted as HTML if the format is <a href="qt.html#TextFormat-enum">Qt.RichText</a>. HTML tags that alter
 
170
the font of the text, its color, or its layout are supported by
 
171
<a href="qstatictext.html">QStaticText</a>.</p>
 
172
<p><b>Note:</b> This function will cause the layout of the text to
 
173
require recalculation.</p>
 
174
<p>See also <a href="qstatictext.html#textFormat">textFormat</a>(),
 
175
<a href="qstatictext.html#setText">setText</a>(), and <a href="qstatictext.html#text">text</a>().</p>
 
176
 
 
177
 
 
178
<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
 
179
to the given <i>textOption</i>.</p>
 
180
<p>See also <a href="qstatictext.html#textOption">textOption</a>().</p>
 
181
 
 
182
 
 
183
<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
 
184
specified width, it will be broken into multiple lines and grow
 
185
vertically. If the text cannot be split into multiple lines, it
 
186
will be larger than the specified <i>textWidth</i>.</p>
 
187
<p>Setting the preferred text width to a negative number will cause
 
188
the text to be unbounded.</p>
 
189
<p>Use <a href="qstatictext.html#size">size</a>() to get the actual
 
190
size of the text.</p>
 
191
<p><b>Note:</b> This function will cause the layout of the text to
 
192
require recalculation.</p>
 
193
<p>See also <a href="qstatictext.html#textWidth">textWidth</a>()
 
194
and <a href="qstatictext.html#size">size</a>().</p>
 
195
 
 
196
 
 
197
<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>
 
198
<p>See also <a href="qstatictext.html#textWidth">textWidth</a>().</p>
 
199
 
 
200
 
 
201
<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>
 
202
<p>See also <a href="qstatictext.html#setText">setText</a>().</p>
 
203
 
 
204
 
 
205
<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>
 
206
<p>See also <a href="qstatictext.html#setTextFormat">setTextFormat</a>(), <a href="qstatictext.html#setText">setText</a>(), and <a href="qstatictext.html#text">text</a>().</p>
 
207
 
 
208
 
 
209
<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
 
210
process.</p>
 
211
<p>See also <a href="qstatictext.html#setTextOption">setTextOption</a>().</p>
 
212
 
 
213
 
 
214
<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>
 
215
<p>See also <a href="qstatictext.html#setTextWidth">setTextWidth</a>().</p>
 
216
 
 
217
 
 
218
<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.8.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.qtsoftware.com">Nokia</a> 2010</td><td align="right" width="25%">Qt&#160;4.7.0</td></tr></table></div></address></body></html>
 
 
b'\\ No newline at end of file'