6
6
td.postheader { font-family: sans-serif }
7
7
tr.address { font-family: sans-serif }
8
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">  </td><td class="postheader" valign="center"><a href="../pyqt4ref.html"><font color="#004faf">Home</font></a> · <a href="classes.html"><font color="#004faf">All Classes</font></a> · <a href="modules.html"><font color="#004faf">Modules</font></a></td></table><h1 align="center">QTextLayout Class Reference<br /><sup><sup>[<a href="qtgui.html">QtGui</a> module]</sup></sup></h1><p>The QTextLayout class is used to lay out and paint a single paragraph of text. <a href="#details">More...</a></p>
10
<h3>Types</h3><ul><li><div class="fn" />enum <b><a href="qtextlayout.html#CursorMode-enum">CursorMode</a></b> { SkipCharacters, SkipWords }</li><li><div class="fn" />class <b><a href="qtextlayout-formatrange.html">FormatRange</a></b></li></ul><h3>Methods</h3><ul><li><div class="fn" /><b><a href="qtextlayout.html#QTextLayout">__init__</a></b> (<i>self</i>)</li><li><div class="fn" /><b><a href="qtextlayout.html#QTextLayout-2">__init__</a></b> (<i>self</i>, QString)</li><li><div class="fn" /><b><a href="qtextlayout.html#QTextLayout-3">__init__</a></b> (<i>self</i>, QString, QFont, QPaintDevice <i>paintDevice</i> = None)</li><li><div class="fn" /><b><a href="qtextlayout.html#QTextLayout-4">__init__</a></b> (<i>self</i>, QTextBlock)</li><li><div class="fn" />list-of-QTextLayout.FormatRange <b><a href="qtextlayout.html#additionalFormats">additionalFormats</a></b> (<i>self</i>)</li><li><div class="fn" /><b><a href="qtextlayout.html#beginLayout">beginLayout</a></b> (<i>self</i>)</li><li><div class="fn" />QRectF <b><a href="qtextlayout.html#boundingRect">boundingRect</a></b> (<i>self</i>)</li><li><div class="fn" />bool <b><a href="qtextlayout.html#cacheEnabled">cacheEnabled</a></b> (<i>self</i>)</li><li><div class="fn" /><b><a href="qtextlayout.html#clearAdditionalFormats">clearAdditionalFormats</a></b> (<i>self</i>)</li><li><div class="fn" /><b><a href="qtextlayout.html#clearLayout">clearLayout</a></b> (<i>self</i>)</li><li><div class="fn" />QTextLine <b><a href="qtextlayout.html#createLine">createLine</a></b> (<i>self</i>)</li><li><div class="fn" /><b><a href="qtextlayout.html#draw">draw</a></b> (<i>self</i>, QPainter, QPointF, list-of-QTextLayout.FormatRange <i>selections</i> = list-of-QTextLayout.FormatRange, QRectF <i>clip</i> = QRectF())</li><li><div class="fn" /><b><a href="qtextlayout.html#drawCursor">drawCursor</a></b> (<i>self</i>, QPainter, QPointF, int)</li><li><div class="fn" /><b><a href="qtextlayout.html#drawCursor-2">drawCursor</a></b> (<i>self</i>, QPainter, QPointF, int, int)</li><li><div class="fn" /><b><a href="qtextlayout.html#endLayout">endLayout</a></b> (<i>self</i>)</li><li><div class="fn" />QFont <b><a href="qtextlayout.html#font">font</a></b> (<i>self</i>)</li><li><div class="fn" />bool <b><a href="qtextlayout.html#isValidCursorPosition">isValidCursorPosition</a></b> (<i>self</i>, int)</li><li><div class="fn" />QTextLine <b><a href="qtextlayout.html#lineAt">lineAt</a></b> (<i>self</i>, int)</li><li><div class="fn" />int <b><a href="qtextlayout.html#lineCount">lineCount</a></b> (<i>self</i>)</li><li><div class="fn" />QTextLine <b><a href="qtextlayout.html#lineForTextPosition">lineForTextPosition</a></b> (<i>self</i>, int)</li><li><div class="fn" />float <b><a href="qtextlayout.html#maximumWidth">maximumWidth</a></b> (<i>self</i>)</li><li><div class="fn" />float <b><a href="qtextlayout.html#minimumWidth">minimumWidth</a></b> (<i>self</i>)</li><li><div class="fn" />int <b><a href="qtextlayout.html#nextCursorPosition">nextCursorPosition</a></b> (<i>self</i>, int, CursorMode <i>mode</i> = QTextLayout.SkipCharacters)</li><li><div class="fn" />QPointF <b><a href="qtextlayout.html#position">position</a></b> (<i>self</i>)</li><li><div class="fn" />int <b><a href="qtextlayout.html#preeditAreaPosition">preeditAreaPosition</a></b> (<i>self</i>)</li><li><div class="fn" />QString <b><a href="qtextlayout.html#preeditAreaText">preeditAreaText</a></b> (<i>self</i>)</li><li><div class="fn" />int <b><a href="qtextlayout.html#previousCursorPosition">previousCursorPosition</a></b> (<i>self</i>, int, CursorMode <i>mode</i> = QTextLayout.SkipCharacters)</li><li><div class="fn" /><b><a href="qtextlayout.html#setAdditionalFormats">setAdditionalFormats</a></b> (<i>self</i>, list-of-QTextLayout.FormatRange)</li><li><div class="fn" /><b><a href="qtextlayout.html#setCacheEnabled">setCacheEnabled</a></b> (<i>self</i>, bool)</li><li><div class="fn" /><b><a href="qtextlayout.html#setFont">setFont</a></b> (<i>self</i>, QFont)</li><li><div class="fn" /><b><a href="qtextlayout.html#setPosition">setPosition</a></b> (<i>self</i>, QPointF)</li><li><div class="fn" /><b><a href="qtextlayout.html#setPreeditArea">setPreeditArea</a></b> (<i>self</i>, int, QString)</li><li><div class="fn" /><b><a href="qtextlayout.html#setText">setText</a></b> (<i>self</i>, QString)</li><li><div class="fn" /><b><a href="qtextlayout.html#setTextOption">setTextOption</a></b> (<i>self</i>, QTextOption)</li><li><div class="fn" />QString <b><a href="qtextlayout.html#text">text</a></b> (<i>self</i>)</li><li><div class="fn" />QTextOption <b><a href="qtextlayout.html#textOption">textOption</a></b> (<i>self</i>)</li></ul><a name="details" /><hr /><h2>Detailed Description</h2><p>The QTextLayout class is used to lay out and paint a single paragraph of text.</p>
11
<p>It offers most features expected from a modern text layout engine, including Unicode compliant rendering, line breaking and handling of cursor positioning. It can also produce and render device independent layout, something that is important for WYSIWYG applications.</p>
12
<p>The class has a rather low level API and unless you intend to implement your own text rendering for some specialized widget, you probably won't need to use it directly.</p>
13
<p>QTextLayout can currently deal with plain text and rich text paragraphs that are part of a <a href="qtextdocument.html">QTextDocument</a>.</p>
14
<p>QTextLayout can be used to create a sequence of <a href="qtextline.html">QTextLine</a>'s with given widths and can position them independently on the screen. Once the layout is done, these lines can be drawn on a paint device.</p>
15
<p>Here's some pseudo code that presents the layout phase:</p>
16
<pre> int leading = fontMetrics.leading();
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">  </td><td class="postheader" valign="center"><a href="../pyqt4ref.html"><font color="#004faf">Home</font></a> · <a href="classes.html"><font color="#004faf">All Classes</font></a> · <a href="modules.html"><font color="#004faf">Modules</font></a></td></table><h1 align="center">QTextLayout Class Reference<br /><sup><sup>[<a href="qtgui.html">QtGui</a> module]</sup></sup></h1><p>The QTextLayout class is used to lay out and render text.
10
<a href="#details">More...</a></p>
12
<h3>Types</h3><ul><li><div class="fn" />enum <b><a href="qtextlayout.html#CursorMode-enum">CursorMode</a></b> { SkipCharacters, SkipWords }</li><li><div class="fn" />class <b><a href="qtextlayout-formatrange.html">FormatRange</a></b></li></ul><h3>Methods</h3><ul><li><div class="fn" /><b><a href="qtextlayout.html#QTextLayout">__init__</a></b> (<i>self</i>)</li><li><div class="fn" /><b><a href="qtextlayout.html#QTextLayout-2">__init__</a></b> (<i>self</i>, QString)</li><li><div class="fn" /><b><a href="qtextlayout.html#QTextLayout-3">__init__</a></b> (<i>self</i>, QString, QFont, QPaintDevice <i>paintDevice</i> = None)</li><li><div class="fn" /><b><a href="qtextlayout.html#QTextLayout-4">__init__</a></b> (<i>self</i>, QTextBlock)</li><li><div class="fn" />list-of-QTextLayout.FormatRange <b><a href="qtextlayout.html#additionalFormats">additionalFormats</a></b> (<i>self</i>)</li><li><div class="fn" /><b><a href="qtextlayout.html#beginLayout">beginLayout</a></b> (<i>self</i>)</li><li><div class="fn" />QRectF <b><a href="qtextlayout.html#boundingRect">boundingRect</a></b> (<i>self</i>)</li><li><div class="fn" />bool <b><a href="qtextlayout.html#cacheEnabled">cacheEnabled</a></b> (<i>self</i>)</li><li><div class="fn" /><b><a href="qtextlayout.html#clearAdditionalFormats">clearAdditionalFormats</a></b> (<i>self</i>)</li><li><div class="fn" /><b><a href="qtextlayout.html#clearLayout">clearLayout</a></b> (<i>self</i>)</li><li><div class="fn" />QTextLine <b><a href="qtextlayout.html#createLine">createLine</a></b> (<i>self</i>)</li><li><div class="fn" /><b><a href="qtextlayout.html#draw">draw</a></b> (<i>self</i>, QPainter, QPointF, list-of-QTextLayout.FormatRange <i>selections</i> = list-of-QTextLayout.FormatRange, QRectF <i>clip</i> = QRectF())</li><li><div class="fn" /><b><a href="qtextlayout.html#drawCursor">drawCursor</a></b> (<i>self</i>, QPainter, QPointF, int)</li><li><div class="fn" /><b><a href="qtextlayout.html#drawCursor-2">drawCursor</a></b> (<i>self</i>, QPainter, QPointF, int, int)</li><li><div class="fn" /><b><a href="qtextlayout.html#endLayout">endLayout</a></b> (<i>self</i>)</li><li><div class="fn" />QFont <b><a href="qtextlayout.html#font">font</a></b> (<i>self</i>)</li><li><div class="fn" />bool <b><a href="qtextlayout.html#isValidCursorPosition">isValidCursorPosition</a></b> (<i>self</i>, int)</li><li><div class="fn" />QTextLine <b><a href="qtextlayout.html#lineAt">lineAt</a></b> (<i>self</i>, int)</li><li><div class="fn" />int <b><a href="qtextlayout.html#lineCount">lineCount</a></b> (<i>self</i>)</li><li><div class="fn" />QTextLine <b><a href="qtextlayout.html#lineForTextPosition">lineForTextPosition</a></b> (<i>self</i>, int)</li><li><div class="fn" />float <b><a href="qtextlayout.html#maximumWidth">maximumWidth</a></b> (<i>self</i>)</li><li><div class="fn" />float <b><a href="qtextlayout.html#minimumWidth">minimumWidth</a></b> (<i>self</i>)</li><li><div class="fn" />int <b><a href="qtextlayout.html#nextCursorPosition">nextCursorPosition</a></b> (<i>self</i>, int, CursorMode <i>mode</i> = QTextLayout.SkipCharacters)</li><li><div class="fn" />QPointF <b><a href="qtextlayout.html#position">position</a></b> (<i>self</i>)</li><li><div class="fn" />int <b><a href="qtextlayout.html#preeditAreaPosition">preeditAreaPosition</a></b> (<i>self</i>)</li><li><div class="fn" />QString <b><a href="qtextlayout.html#preeditAreaText">preeditAreaText</a></b> (<i>self</i>)</li><li><div class="fn" />int <b><a href="qtextlayout.html#previousCursorPosition">previousCursorPosition</a></b> (<i>self</i>, int, CursorMode <i>mode</i> = QTextLayout.SkipCharacters)</li><li><div class="fn" /><b><a href="qtextlayout.html#setAdditionalFormats">setAdditionalFormats</a></b> (<i>self</i>, list-of-QTextLayout.FormatRange)</li><li><div class="fn" /><b><a href="qtextlayout.html#setCacheEnabled">setCacheEnabled</a></b> (<i>self</i>, bool)</li><li><div class="fn" /><b><a href="qtextlayout.html#setFont">setFont</a></b> (<i>self</i>, QFont)</li><li><div class="fn" /><b><a href="qtextlayout.html#setPosition">setPosition</a></b> (<i>self</i>, QPointF)</li><li><div class="fn" /><b><a href="qtextlayout.html#setPreeditArea">setPreeditArea</a></b> (<i>self</i>, int, QString)</li><li><div class="fn" /><b><a href="qtextlayout.html#setText">setText</a></b> (<i>self</i>, QString)</li><li><div class="fn" /><b><a href="qtextlayout.html#setTextOption">setTextOption</a></b> (<i>self</i>, QTextOption)</li><li><div class="fn" />QString <b><a href="qtextlayout.html#text">text</a></b> (<i>self</i>)</li><li><div class="fn" />QTextOption <b><a href="qtextlayout.html#textOption">textOption</a></b> (<i>self</i>)</li></ul><a name="details" /><hr /><h2>Detailed Description</h2><p>The QTextLayout class is used to lay out and render text.</p>
13
<p>It offers many features expected from a modern text layout
14
engine, including Unicode compliant rendering, line breaking and
15
handling of cursor positioning. It can also produce and render
16
device independent layout, something that is important for WYSIWYG
18
<p>The class has a rather low level API and unless you intend to
19
implement your own text rendering for some specialized widget, you
20
probably won't need to use it directly.</p>
21
<p>QTextLayout can be used with both plain and rich text.</p>
22
<p>QTextLayout can be used to create a sequence of <a href="qtextline.html">QTextLine</a> instances with given widths and can
23
position them independently on the screen. Once the layout is done,
24
these lines can be drawn on a paint device.</p>
25
<p>The text to be laid out can be provided in the constructor or
26
set with <a href="qtextlayout.html#setText">setText</a>().</p>
27
<p>The layout can be seen as a sequence of <a href="qtextline.html">QTextLine</a> objects; use <a href="qtextlayout.html#createLine">createLine</a>() to create a <a href="qtextline.html">QTextLine</a> instance, and <a href="qtextlayout.html#lineAt">lineAt</a>() or <a href="qtextlayout.html#lineForTextPosition">lineForTextPosition</a>() to
28
retrieve created lines.</p>
29
<p>Here is a code snippet that demonstrates the layout phase:</p>
30
<pre class="highlightedCode brush: cpp">
31
int leading = fontMetrics.leading();
19
33
textLayout.beginLayout();
21
35
QTextLine line = textLayout.createLine();
27
41
line.setPosition(QPointF(0, height));
28
42
height += line.height();
29
widthUsed = qMax(widthUsed, line.naturalTextWidth());
31
textLayout.endLayout();</pre>
32
<p>The text can be drawn by calling the layout's <a href="qtextlayout.html#draw">draw</a>() function:</p>
33
<pre> QPainter painter(this);
34
textLayout.draw(&painter, QPoint(0, 0));</pre>
35
<p>The text layout's text is set in the constructor or with <a href="qtextlayout.html#setText">setText</a>(). The layout can be seen as a sequence of <a href="qtextline.html">QTextLine</a> objects; use <a href="qtextlayout.html#lineAt">lineAt</a>() or <a href="qtextlayout.html#lineForTextPosition">lineForTextPosition</a>() to get a <a href="qtextline.html">QTextLine</a>, <a href="qtextlayout.html#createLine">createLine</a>() to create one. For a given position in the text you can find a valid cursor position with <a href="qtextlayout.html#isValidCursorPosition">isValidCursorPosition</a>(), <a href="qtextlayout.html#nextCursorPosition">nextCursorPosition</a>(), and <a href="qtextlayout.html#previousCursorPosition">previousCursorPosition</a>(). The layout itself can be positioned with <a href="qtextlayout.html#setPosition">setPosition</a>(); it has a <a href="qtextlayout.html#boundingRect">boundingRect</a>(), and a <a href="qtextlayout.html#minimumWidth">minimumWidth</a>() and a <a href="qtextlayout.html#maximumWidth">maximumWidth</a>(). A text layout can be drawn on a painter device using <a href="qtextlayout.html#draw">draw</a>().</p>
36
<hr /><h2>Type Documentation</h2><h3 class="fn"><a name="CursorMode-enum" />QTextLayout.CursorMode</h3><p><table border="1" cellpadding="2" cellspacing="1" class="valuelist" width="40%">
37
<tr><th width="60%">Constant</th><th width="40%">Value</th></tr>
38
<tr><td valign="top"><tt>QTextLayout.SkipCharacters</tt></td><td align="center" valign="top"><tt>0</tt></td></tr>
39
<tr><td valign="top"><tt>QTextLayout.SkipWords</tt></td><td align="center" valign="top"><tt>1</tt></td></tr>
44
textLayout.endLayout();
46
<p>The text can then be rendered by calling the layout's <a href="qtextlayout.html#draw">draw</a>() function:</p>
47
<pre class="highlightedCode brush: cpp">
48
QPainter painter(this);
49
textLayout.draw(&painter, QPoint(0, 0));
51
<p>For a given position in the text you can find a valid cursor
52
position with <a href="qtextlayout.html#isValidCursorPosition">isValidCursorPosition</a>(),
53
<a href="qtextlayout.html#nextCursorPosition">nextCursorPosition</a>(), and
54
<a href="qtextlayout.html#previousCursorPosition">previousCursorPosition</a>().</p>
55
<p>The QTextLayout itself can be positioned with <a href="qtextlayout.html#setPosition">setPosition</a>(); it has a <a href="qtextlayout.html#boundingRect">boundingRect</a>(), and a <a href="qtextlayout.html#minimumWidth">minimumWidth</a>() and a <a href="qtextlayout.html#maximumWidth">maximumWidth</a>().</p>
56
<hr /><h2>Type Documentation</h2><h3 class="fn"><a name="CursorMode-enum" />QTextLayout.CursorMode</h3><table class="valuelist">
58
<th class="tblConst">Constant</th>
59
<th class="tblVal">Value</th>
62
<td class="topAlign"><tt>QTextLayout.SkipCharacters</tt></td>
63
<td class=" topAlign"><tt>0</tt></td>
66
<td class="topAlign"><tt>QTextLayout.SkipWords</tt></td>
67
<td class=" topAlign"><tt>1</tt></td>
41
70
<hr /><h2>Method Documentation</h2><h3 class="fn"><a name="QTextLayout" />QTextLayout.__init__ (<i>self</i>)</h3><p>Constructs an empty text layout.</p>
42
71
<p>See also <a href="qtextlayout.html#setText">setText</a>().</p>
43
74
<h3 class="fn"><a name="QTextLayout-2" />QTextLayout.__init__ (<i>self</i>, QString)</h3><p>Constructs a text layout to lay out the given <i>text</i>.</p>
44
<h3 class="fn"><a name="QTextLayout-3" />QTextLayout.__init__ (<i>self</i>, QString, <a href="qfont.html">QFont</a>, <a href="qpaintdevice.html">QPaintDevice</a> <i>paintDevice</i> = None)</h3><p>Constructs a text layout to lay out the given <i>text</i> with the specified <i>font</i>.</p>
45
<p>All the metric and layout calculations will be done in terms of the paint device, <i>paintdevice</i>. If <i>paintdevice</i> is 0 the calculations will be done in screen metrics.</p>
46
<a name="//apple_ref/cpp/instm/QTextLayout/~QTextLayout" />
47
<h3 class="fn"><a name="QTextLayout-4" />QTextLayout.__init__ (<i>self</i>, <a href="qtextblock.html">QTextBlock</a>)</h3><h3 class="fn"><a name="additionalFormats" />list-of-QTextLayout.FormatRange QTextLayout.additionalFormats (<i>self</i>)</h3><p>Returns the list of additional formats supported by the text layout.</p>
48
<p>See also <a href="qtextlayout.html#setAdditionalFormats">setAdditionalFormats</a>() and <a href="qtextlayout.html#clearAdditionalFormats">clearAdditionalFormats</a>().</p>
49
<a name="//apple_ref/cpp/instm/QTextLayout/beginLayout" />
77
<h3 class="fn"><a name="QTextLayout-3" />QTextLayout.__init__ (<i>self</i>, QString, <a href="qfont.html">QFont</a>, <a href="qpaintdevice.html">QPaintDevice</a> <i>paintDevice</i> = None)</h3><p>Constructs a text layout to lay out the given <i>text</i> with
78
the specified <i>font</i>.</p>
79
<p>All the metric and layout calculations will be done in terms of
80
the paint device, <i>paintdevice</i>. If <i>paintdevice</i> is 0
81
the calculations will be done in screen metrics.</p>
84
<h3 class="fn"><a name="QTextLayout-4" />QTextLayout.__init__ (<i>self</i>, <a href="qtextblock.html">QTextBlock</a>)</h3><h3 class="fn"><a name="additionalFormats" />list-of-QTextLayout.FormatRange QTextLayout.additionalFormats (<i>self</i>)</h3><p>Returns the list of additional formats supported by the text
86
<p>See also <a href="qtextlayout.html#setAdditionalFormats">setAdditionalFormats</a>()
87
and <a href="qtextlayout.html#clearAdditionalFormats">clearAdditionalFormats</a>().</p>
50
90
<h3 class="fn"><a name="beginLayout" />QTextLayout.beginLayout (<i>self</i>)</h3><p>Begins the layout process.</p>
51
<a name="//apple_ref/cpp/instm/QTextLayout/boundingRect" />
52
<h3 class="fn"><a name="boundingRect" /><a href="qrectf.html">QRectF</a> QTextLayout.boundingRect (<i>self</i>)</h3><p>The smallest rectangle that contains all the lines in the layout.</p>
53
<a name="//apple_ref/cpp/instm/QTextLayout/cacheEnabled" />
54
<h3 class="fn"><a name="cacheEnabled" />bool QTextLayout.cacheEnabled (<i>self</i>)</h3><p>Returns true if the complete layout information is cached; otherwise returns false.</p>
93
<h3 class="fn"><a name="boundingRect" /><a href="qrectf.html">QRectF</a> QTextLayout.boundingRect (<i>self</i>)</h3><p>The smallest rectangle that contains all the lines in the
97
<h3 class="fn"><a name="cacheEnabled" />bool QTextLayout.cacheEnabled (<i>self</i>)</h3><p>Returns true if the complete layout information is cached;
98
otherwise returns false.</p>
55
99
<p>See also <a href="qtextlayout.html#setCacheEnabled">setCacheEnabled</a>().</p>
56
<a name="//apple_ref/cpp/instm/QTextLayout/clearAdditionalFormats" />
57
<h3 class="fn"><a name="clearAdditionalFormats" />QTextLayout.clearAdditionalFormats (<i>self</i>)</h3><p>Clears the list of additional formats supported by the text layout.</p>
58
<p>See also <a href="qtextlayout.html#additionalFormats">additionalFormats</a>() and <a href="qtextlayout.html#setAdditionalFormats">setAdditionalFormats</a>().</p>
59
<a name="//apple_ref/cpp/instm/QTextLayout/clearLayout" />
60
<h3 class="fn"><a name="clearLayout" />QTextLayout.clearLayout (<i>self</i>)</h3><p>Clears the line information in the layout. After having called this function, <a href="qtextlayout.html#lineCount">lineCount</a>() returns 0.</p>
102
<h3 class="fn"><a name="clearAdditionalFormats" />QTextLayout.clearAdditionalFormats (<i>self</i>)</h3><p>Clears the list of additional formats supported by the text
104
<p>See also <a href="qtextlayout.html#additionalFormats">additionalFormats</a>() and
105
<a href="qtextlayout.html#setAdditionalFormats">setAdditionalFormats</a>().</p>
108
<h3 class="fn"><a name="clearLayout" />QTextLayout.clearLayout (<i>self</i>)</h3><p>Clears the line information in the layout. After having called
109
this function, <a href="qtextlayout.html#lineCount">lineCount</a>()
61
111
<p>This function was introduced in Qt 4.4.</p>
62
<a name="//apple_ref/cpp/instm/QTextLayout/createLine" />
63
<h3 class="fn"><a name="createLine" /><a href="qtextline.html">QTextLine</a> QTextLayout.createLine (<i>self</i>)</h3><p>Returns a new text line to be laid out if there is text to be inserted into the layout; otherwise returns an invalid text line.</p>
64
<p>The text layout creates a new line object that starts after the last line in the layout, or at the beginning if the layout is empty. The layout maintains an internal cursor, and each line is filled with text from the cursor position onwards when the <a href="qtextline.html#setLineWidth">QTextLine.setLineWidth</a>() function is called.</p>
65
<p>Once <a href="qtextline.html#setLineWidth">QTextLine.setLineWidth</a>() is called, a new line can be created and filled with text. Repeating this process will lay out the whole block of text contained in the <a href="qtextlayout.html">QTextLayout</a>. If there is no text left to be inserted into the layout, the <a href="qtextline.html">QTextLine</a> returned will not be valid (isValid() will return false).</p>
66
<a name="//apple_ref/cpp/instm/QTextLayout/draw" />
67
<h3 class="fn"><a name="draw" />QTextLayout.draw (<i>self</i>, <a href="qpainter.html">QPainter</a>, <a href="qpointf.html">QPointF</a>, list-of-QTextLayout.FormatRange <i>selections</i> = list-of-QTextLayout.FormatRange, <a href="qrectf.html">QRectF</a> <i>clip</i> = QRectF())</h3><p>Draws the whole layout on the painter <i>p</i> at the position specified by <i>pos</i>. The rendered layout includes the given <i>selections</i> and is clipped within the rectangle specified by <i>clip</i>.</p>
68
<a name="//apple_ref/cpp/instm/QTextLayout/drawCursor" />
69
<h3 class="fn"><a name="drawCursor" />QTextLayout.drawCursor (<i>self</i>, <a href="qpainter.html">QPainter</a>, <a href="qpointf.html">QPointF</a>, int)</h3><p>Draws a text cursor with the current pen and the specified <i>width</i> at the given <i>position</i> using the <i>painter</i> specified. The corresponding position within the text is specified by <i>cursorPosition</i>.</p>
114
<h3 class="fn"><a name="createLine" /><a href="qtextline.html">QTextLine</a> QTextLayout.createLine (<i>self</i>)</h3><p>Returns a new text line to be laid out if there is text to be
115
inserted into the layout; otherwise returns an invalid text
117
<p>The text layout creates a new line object that starts after the
118
last line in the layout, or at the beginning if the layout is
119
empty. The layout maintains an internal cursor, and each line is
120
filled with text from the cursor position onwards when the <a href="qtextline.html#setLineWidth">QTextLine.setLineWidth</a>()
121
function is called.</p>
122
<p>Once <a href="qtextline.html#setLineWidth">QTextLine.setLineWidth</a>() is
123
called, a new line can be created and filled with text. Repeating
124
this process will lay out the whole block of text contained in the
125
<a href="qtextlayout.html">QTextLayout</a>. If there is no text
126
left to be inserted into the layout, the <a href="qtextline.html">QTextLine</a> returned will not be valid
127
(isValid() will return false).</p>
130
<h3 class="fn"><a name="draw" />QTextLayout.draw (<i>self</i>, <a href="qpainter.html">QPainter</a>, <a href="qpointf.html">QPointF</a>, list-of-QTextLayout.FormatRange <i>selections</i> = list-of-QTextLayout.FormatRange, <a href="qrectf.html">QRectF</a> <i>clip</i> = QRectF())</h3><p>Draws the whole layout on the painter <i>p</i> at the position
131
specified by <i>pos</i>. The rendered layout includes the given
132
<i>selections</i> and is clipped within the rectangle specified by
136
<h3 class="fn"><a name="drawCursor" />QTextLayout.drawCursor (<i>self</i>, <a href="qpainter.html">QPainter</a>, <a href="qpointf.html">QPointF</a>, int)</h3><p>Draws a text cursor with the current pen and the specified
137
<i>width</i> at the given <i>position</i> using the <i>painter</i>
138
specified. The corresponding position within the text is specified
139
by <i>cursorPosition</i>.</p>
70
142
<h3 class="fn"><a name="drawCursor-2" />QTextLayout.drawCursor (<i>self</i>, <a href="qpainter.html">QPainter</a>, <a href="qpointf.html">QPointF</a>, int, int)</h3><p>This is an overloaded function.</p>
71
<p>Draws a text cursor with the current pen at the given <i>position</i> using the <i>painter</i> specified. The corresponding position within the text is specified by <i>cursorPosition</i>.</p>
72
<a name="//apple_ref/cpp/instm/QTextLayout/endLayout" />
143
<p>Draws a text cursor with the current pen at the given
144
<i>position</i> using the <i>painter</i> specified. The
145
corresponding position within the text is specified by
146
<i>cursorPosition</i>.</p>
73
149
<h3 class="fn"><a name="endLayout" />QTextLayout.endLayout (<i>self</i>)</h3><p>Ends the layout process.</p>
74
<a name="//apple_ref/cpp/instm/QTextLayout/font" />
75
<h3 class="fn"><a name="font" /><a href="qfont.html">QFont</a> QTextLayout.font (<i>self</i>)</h3><p>Returns the current font that is used for the layout, or a default font if none is set.</p>
152
<h3 class="fn"><a name="font" /><a href="qfont.html">QFont</a> QTextLayout.font (<i>self</i>)</h3><p>Returns the current font that is used for the layout, or a
153
default font if none is set.</p>
76
154
<p>See also <a href="qtextlayout.html#setFont">setFont</a>().</p>
77
<a name="//apple_ref/cpp/instm/QTextLayout/isValidCursorPosition" />
78
<h3 class="fn"><a name="isValidCursorPosition" />bool QTextLayout.isValidCursorPosition (<i>self</i>, int)</h3><p>Returns true if position <i>pos</i> is a valid cursor position.</p>
79
<p>In a Unicode context some positions in the text are not valid cursor positions, because the position is inside a Unicode surrogate or a grapheme cluster.</p>
80
<p>A grapheme cluster is a sequence of two or more Unicode characters that form one indivisible entity on the screen. For example the latin character `Ä' can be represented in Unicode by two characters, `A' (0x41), and the combining diaresis (0x308). A text cursor can only validly be positioned before or after these two characters, never between them since that wouldn't make sense. In indic languages every syllable forms a grapheme cluster.</p>
81
<a name="//apple_ref/cpp/instm/QTextLayout/lineAt" />
157
<h3 class="fn"><a name="isValidCursorPosition" />bool QTextLayout.isValidCursorPosition (<i>self</i>, int)</h3><p>Returns true if position <i>pos</i> is a valid cursor
159
<p>In a Unicode context some positions in the text are not valid
160
cursor positions, because the position is inside a Unicode
161
surrogate or a grapheme cluster.</p>
162
<p>A grapheme cluster is a sequence of two or more Unicode
163
characters that form one indivisible entity on the screen. For
164
example the latin character `Ä' can be represented in Unicode
165
by two characters, `A' (0x41), and the combining diaresis (0x308).
166
A text cursor can only validly be positioned before or after these
167
two characters, never between them since that wouldn't make sense.
168
In indic languages every syllable forms a grapheme cluster.</p>
82
171
<h3 class="fn"><a name="lineAt" /><a href="qtextline.html">QTextLine</a> QTextLayout.lineAt (<i>self</i>, int)</h3><p>Returns the <i>i</i>-th line of text in this text layout.</p>
83
<p>See also <a href="qtextlayout.html#lineCount">lineCount</a>() and <a href="qtextlayout.html#lineForTextPosition">lineForTextPosition</a>().</p>
84
<a name="//apple_ref/cpp/instm/QTextLayout/lineCount" />
172
<p>See also <a href="qtextlayout.html#lineCount">lineCount</a>()
173
and <a href="qtextlayout.html#lineForTextPosition">lineForTextPosition</a>().</p>
85
176
<h3 class="fn"><a name="lineCount" />int QTextLayout.lineCount (<i>self</i>)</h3><p>Returns the number of lines in this text layout.</p>
86
177
<p>See also <a href="qtextlayout.html#lineAt">lineAt</a>().</p>
87
<a name="//apple_ref/cpp/instm/QTextLayout/lineForTextPosition" />
88
<h3 class="fn"><a name="lineForTextPosition" /><a href="qtextline.html">QTextLine</a> QTextLayout.lineForTextPosition (<i>self</i>, int)</h3><p>Returns the line that contains the cursor position specified by <i>pos</i>.</p>
89
<p>See also <a href="qtextlayout.html#isValidCursorPosition">isValidCursorPosition</a>() and <a href="qtextlayout.html#lineAt">lineAt</a>().</p>
90
<a name="//apple_ref/cpp/instm/QTextLayout/maximumWidth" />
91
<h3 class="fn"><a name="maximumWidth" />float QTextLayout.maximumWidth (<i>self</i>)</h3><p>The maximum width the layout could expand to; this is essentially the width of the entire text.</p>
92
<p><b>Warning:</b> This function only returns a valid value after the layout has been done.</p>
180
<h3 class="fn"><a name="lineForTextPosition" /><a href="qtextline.html">QTextLine</a> QTextLayout.lineForTextPosition (<i>self</i>, int)</h3><p>Returns the line that contains the cursor position specified by
182
<p>See also <a href="qtextlayout.html#isValidCursorPosition">isValidCursorPosition</a>()
183
and <a href="qtextlayout.html#lineAt">lineAt</a>().</p>
186
<h3 class="fn"><a name="maximumWidth" />float QTextLayout.maximumWidth (<i>self</i>)</h3><p>The maximum width the layout could expand to; this is
187
essentially the width of the entire text.</p>
188
<p><b>Warning:</b> This function only returns a valid value after
189
the layout has been done.</p>
93
190
<p>See also <a href="qtextlayout.html#minimumWidth">minimumWidth</a>().</p>
94
<a name="//apple_ref/cpp/instm/QTextLayout/minimumWidth" />
95
<h3 class="fn"><a name="minimumWidth" />float QTextLayout.minimumWidth (<i>self</i>)</h3><p>The minimum width the layout needs. This is the width of the layout's smallest non-breakable substring.</p>
96
<p><b>Warning:</b> This function only returns a valid value after the layout has been done.</p>
193
<h3 class="fn"><a name="minimumWidth" />float QTextLayout.minimumWidth (<i>self</i>)</h3><p>The minimum width the layout needs. This is the width of the
194
layout's smallest non-breakable substring.</p>
195
<p><b>Warning:</b> This function only returns a valid value after
196
the layout has been done.</p>
97
197
<p>See also <a href="qtextlayout.html#maximumWidth">maximumWidth</a>().</p>
98
<a name="//apple_ref/cpp/instm/QTextLayout/nextCursorPosition" />
99
<h3 class="fn"><a name="nextCursorPosition" />int QTextLayout.nextCursorPosition (<i>self</i>, int, <a href="qtextlayout.html#CursorMode-enum">CursorMode</a> <i>mode</i> = QTextLayout.SkipCharacters)</h3><p>Returns the next valid cursor position after <i>oldPos</i> that respects the given cursor <i>mode</i>.</p>
100
<p>See also <a href="qtextlayout.html#isValidCursorPosition">isValidCursorPosition</a>() and <a href="qtextlayout.html#previousCursorPosition">previousCursorPosition</a>().</p>
101
<a name="//apple_ref/cpp/instm/QTextLayout/position" />
102
<h3 class="fn"><a name="position" /><a href="qpointf.html">QPointF</a> QTextLayout.position (<i>self</i>)</h3><p>The global position of the layout. This is independent of the bounding rectangle and of the layout process.</p>
200
<h3 class="fn"><a name="nextCursorPosition" />int QTextLayout.nextCursorPosition (<i>self</i>, int, <a href="qtextlayout.html#CursorMode-enum">CursorMode</a> <i>mode</i> = QTextLayout.SkipCharacters)</h3><p>Returns the next valid cursor position after <i>oldPos</i> that
201
respects the given cursor <i>mode</i>.</p>
202
<p>See also <a href="qtextlayout.html#isValidCursorPosition">isValidCursorPosition</a>()
203
and <a href="qtextlayout.html#previousCursorPosition">previousCursorPosition</a>().</p>
206
<h3 class="fn"><a name="position" /><a href="qpointf.html">QPointF</a> QTextLayout.position (<i>self</i>)</h3><p>The global position of the layout. This is independent of the
207
bounding rectangle and of the layout process.</p>
103
208
<p>This function was introduced in Qt 4.2.</p>
104
209
<p>See also <a href="qtextlayout.html#setPosition">setPosition</a>().</p>
105
<a name="//apple_ref/cpp/instm/QTextLayout/preeditAreaPosition" />
106
<h3 class="fn"><a name="preeditAreaPosition" />int QTextLayout.preeditAreaPosition (<i>self</i>)</h3><p>Returns the position of the area in the text layout that will be processed before editing occurs.</p>
107
<a name="//apple_ref/cpp/instm/QTextLayout/preeditAreaText" />
108
<h3 class="fn"><a name="preeditAreaText" />QString QTextLayout.preeditAreaText (<i>self</i>)</h3><p>Returns the text that is inserted in the layout before editing occurs.</p>
109
<a name="//apple_ref/cpp/instm/QTextLayout/previousCursorPosition" />
110
<h3 class="fn"><a name="previousCursorPosition" />int QTextLayout.previousCursorPosition (<i>self</i>, int, <a href="qtextlayout.html#CursorMode-enum">CursorMode</a> <i>mode</i> = QTextLayout.SkipCharacters)</h3><p>Returns the first valid cursor position before <i>oldPos</i> that respects the given cursor <i>mode</i>.</p>
111
<p>See also <a href="qtextlayout.html#isValidCursorPosition">isValidCursorPosition</a>() and <a href="qtextlayout.html#nextCursorPosition">nextCursorPosition</a>().</p>
112
<a name="//apple_ref/cpp/instm/QTextLayout/setAdditionalFormats" />
113
<h3 class="fn"><a name="setAdditionalFormats" />QTextLayout.setAdditionalFormats (<i>self</i>, list-of-QTextLayout.FormatRange)</h3><p>Sets the additional formats supported by the text layout to <i>formatList</i>.</p>
114
<p>See also <a href="qtextlayout.html#additionalFormats">additionalFormats</a>() and <a href="qtextlayout.html#clearAdditionalFormats">clearAdditionalFormats</a>().</p>
115
<a name="//apple_ref/cpp/instm/QTextLayout/setCacheEnabled" />
116
<h3 class="fn"><a name="setCacheEnabled" />QTextLayout.setCacheEnabled (<i>self</i>, bool)</h3><p>Enables caching of the complete layout information if <i>enable</i> is true; otherwise disables layout caching. Usually <a href="qtextlayout.html">QTextLayout</a> throws most of the layouting information away after a call to <a href="qtextlayout.html#endLayout">endLayout</a>() to reduce memory consumption. If you however want to draw the laid out text directly afterwards enabling caching might speed up drawing significantly.</p>
212
<h3 class="fn"><a name="preeditAreaPosition" />int QTextLayout.preeditAreaPosition (<i>self</i>)</h3><p>Returns the position of the area in the text layout that will be
213
processed before editing occurs.</p>
216
<h3 class="fn"><a name="preeditAreaText" />QString QTextLayout.preeditAreaText (<i>self</i>)</h3><p>Returns the text that is inserted in the layout before editing
220
<h3 class="fn"><a name="previousCursorPosition" />int QTextLayout.previousCursorPosition (<i>self</i>, int, <a href="qtextlayout.html#CursorMode-enum">CursorMode</a> <i>mode</i> = QTextLayout.SkipCharacters)</h3><p>Returns the first valid cursor position before <i>oldPos</i>
221
that respects the given cursor <i>mode</i>.</p>
222
<p>See also <a href="qtextlayout.html#isValidCursorPosition">isValidCursorPosition</a>()
223
and <a href="qtextlayout.html#nextCursorPosition">nextCursorPosition</a>().</p>
226
<h3 class="fn"><a name="setAdditionalFormats" />QTextLayout.setAdditionalFormats (<i>self</i>, list-of-QTextLayout.FormatRange)</h3><p>Sets the additional formats supported by the text layout to
227
<i>formatList</i>.</p>
228
<p>See also <a href="qtextlayout.html#additionalFormats">additionalFormats</a>() and
229
<a href="qtextlayout.html#clearAdditionalFormats">clearAdditionalFormats</a>().</p>
232
<h3 class="fn"><a name="setCacheEnabled" />QTextLayout.setCacheEnabled (<i>self</i>, bool)</h3><p>Enables caching of the complete layout information if
233
<i>enable</i> is true; otherwise disables layout caching. Usually
234
<a href="qtextlayout.html">QTextLayout</a> throws most of the
235
layouting information away after a call to <a href="qtextlayout.html#endLayout">endLayout</a>() to reduce memory
236
consumption. If you however want to draw the laid out text directly
237
afterwards enabling caching might speed up drawing
117
239
<p>See also <a href="qtextlayout.html#cacheEnabled">cacheEnabled</a>().</p>
118
<a name="//apple_ref/cpp/instm/QTextLayout/setFont" />
119
<h3 class="fn"><a name="setFont" />QTextLayout.setFont (<i>self</i>, <a href="qfont.html">QFont</a>)</h3><p>Sets the layout's font to the given <i>font</i>. The layout is invalidated and must be laid out again.</p>
242
<h3 class="fn"><a name="setFont" />QTextLayout.setFont (<i>self</i>, <a href="qfont.html">QFont</a>)</h3><p>Sets the layout's font to the given <i>font</i>. The layout is
243
invalidated and must be laid out again.</p>
120
244
<p>See also <a href="qtextlayout.html#font">font</a>() and <a href="qtextlayout.html#text">text</a>().</p>
121
<a name="//apple_ref/cpp/instm/QTextLayout/setPosition" />
122
247
<h3 class="fn"><a name="setPosition" />QTextLayout.setPosition (<i>self</i>, <a href="qpointf.html">QPointF</a>)</h3><p>Moves the text layout to point <i>p</i>.</p>
123
248
<p>See also <a href="qtextlayout.html#position">position</a>().</p>
124
<a name="//apple_ref/cpp/instm/QTextLayout/setPreeditArea" />
125
<h3 class="fn"><a name="setPreeditArea" />QTextLayout.setPreeditArea (<i>self</i>, int, QString)</h3><p>Sets the <i>position</i> and <i>text</i> of the area in the layout that is processed before editing occurs.</p>
126
<a name="//apple_ref/cpp/instm/QTextLayout/setText" />
127
<h3 class="fn"><a name="setText" />QTextLayout.setText (<i>self</i>, QString)</h3><p>Sets the layout's text to the given <i>string</i>. The layout is invalidated and must be laid out again.</p>
128
<p>Notice that when using this <a href="qtextlayout.html">QTextLayout</a> as part of a <a href="qtextdocument.html">QTextDocument</a> this method will have no effect.</p>
251
<h3 class="fn"><a name="setPreeditArea" />QTextLayout.setPreeditArea (<i>self</i>, int, QString)</h3><p>Sets the <i>position</i> and <i>text</i> of the area in the
252
layout that is processed before editing occurs.</p>
255
<h3 class="fn"><a name="setText" />QTextLayout.setText (<i>self</i>, QString)</h3><p>Sets the layout's text to the given <i>string</i>. The layout is
256
invalidated and must be laid out again.</p>
257
<p>Notice that when using this <a href="qtextlayout.html">QTextLayout</a> as part of a <a href="qtextdocument.html">QTextDocument</a> this method will have no
129
259
<p>See also <a href="qtextlayout.html#text">text</a>().</p>
130
<a name="//apple_ref/cpp/instm/QTextLayout/setTextOption" />
131
<h3 class="fn"><a name="setTextOption" />QTextLayout.setTextOption (<i>self</i>, <a href="qtextoption.html">QTextOption</a>)</h3><p>Sets the text option structure that controls the layout process to the given <i>option</i>.</p>
132
<p>See also <a href="qtextlayout.html#textOption">textOption</a>() and <a href="qtextoption.html">QTextOption</a>.</p>
133
<a name="//apple_ref/cpp/instm/QTextLayout/text" />
262
<h3 class="fn"><a name="setTextOption" />QTextLayout.setTextOption (<i>self</i>, <a href="qtextoption.html">QTextOption</a>)</h3><p>Sets the text option structure that controls the layout process
263
to the given <i>option</i>.</p>
264
<p>See also <a href="qtextlayout.html#textOption">textOption</a>()
265
and <a href="qtextoption.html">QTextOption</a>.</p>
134
268
<h3 class="fn"><a name="text" />QString QTextLayout.text (<i>self</i>)</h3><p>Returns the layout's text.</p>
135
269
<p>See also <a href="qtextlayout.html#setText">setText</a>().</p>
136
<a name="//apple_ref/cpp/instm/QTextLayout/textOption" />
137
<h3 class="fn"><a name="textOption" /><a href="qtextoption.html">QTextOption</a> QTextLayout.textOption (<i>self</i>)</h3><p>Returns the current text option used to control the layout process.</p>
272
<h3 class="fn"><a name="textOption" /><a href="qtextoption.html">QTextOption</a> QTextLayout.textOption (<i>self</i>)</h3><p>Returns the current text option used to control the layout
138
274
<p>See also <a href="qtextlayout.html#setTextOption">setTextOption</a>() and <a href="qtextoption.html">QTextOption</a>.</p>
139
<p /><address><hr /><div align="center"><table border="0" cellspacing="0" width="100%"><tr class="address"><td align="left" width="25%">PyQt 4.7.7 for X11</td><td align="center" width="50%">Copyright © <a href="http://www.riverbankcomputing.com">Riverbank Computing Ltd</a> and <a href="http://www.qtsoftware.com">Nokia</a> 2010</td><td align="right" width="25%">Qt 4.6.3</td></tr></table></div></address></body></html>
b'\\ No newline at end of file'
275
<address><hr /><div align="center"><table border="0" cellspacing="0" width="100%"><tr class="address"><td align="left" width="25%">PyQt 4.8.1 for X11</td><td align="center" width="50%">Copyright © <a href="http://www.riverbankcomputing.com">Riverbank Computing Ltd</a> and <a href="http://www.qtsoftware.com">Nokia</a> 2010</td><td align="right" width="25%">Qt 4.7.0</td></tr></table></div></address></body></html>
b'\\ No newline at end of file'