File: qtextline.html

package info (click to toggle)
python-qt4 4.12.1%2Bdfsg-2
  • links: PTS, VCS
  • area: main
  • in suites: buster
  • size: 40,300 kB
  • ctags: 6,185
  • sloc: python: 125,988; cpp: 13,291; xml: 292; makefile: 246; php: 27; sh: 2
file content (195 lines) | stat: -rw-r--r-- 16,300 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
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
<?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>QTextLine 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">QTextLine Class Reference<br /><sup><sup>[<a href="qtgui.html">QtGui</a> module]</sup></sup></h1><p>The QTextLine class represents a line of text inside a <a href="qtextlayout.html">QTextLayout</a>. <a href="#details">More...</a></p>

<h3>Types</h3><ul><li><div class="fn" />enum <b><a href="qtextline.html#CursorPosition-enum">CursorPosition</a></b> { CursorBetweenCharacters, CursorOnCharacter }</li><li><div class="fn" />enum <b><a href="qtextline.html#Edge-enum">Edge</a></b> { Leading, Trailing }</li></ul><h3>Methods</h3><ul><li><div class="fn" /><b><a href="qtextline.html#QTextLine">__init__</a></b> (<i>self</i>)</li><li><div class="fn" /><b><a href="qtextline.html#QTextLine-2">__init__</a></b> (<i>self</i>, QTextLine)</li><li><div class="fn" />float <b><a href="qtextline.html#ascent">ascent</a></b> (<i>self</i>)</li><li><div class="fn" />(float, int&#160;<i>cursorPos</i>) <b><a href="qtextline.html#cursorToX">cursorToX</a></b> (<i>self</i>, int&#160;<i>cursorPos</i>, Edge&#160;<i>edge</i>&#160;=&#160;QTextLine.Leading)</li><li><div class="fn" />float <b><a href="qtextline.html#descent">descent</a></b> (<i>self</i>)</li><li><div class="fn" /><b><a href="qtextline.html#draw">draw</a></b> (<i>self</i>, QPainter&#160;<i>painter</i>, QPointF&#160;<i>position</i>, QTextLayout.FormatRange&#160;<i>selection</i>&#160;=&#160;None)</li><li><div class="fn" />float <b><a href="qtextline.html#height">height</a></b> (<i>self</i>)</li><li><div class="fn" />float <b><a href="qtextline.html#horizontalAdvance">horizontalAdvance</a></b> (<i>self</i>)</li><li><div class="fn" />bool <b><a href="qtextline.html#isValid">isValid</a></b> (<i>self</i>)</li><li><div class="fn" />float <b><a href="qtextline.html#leading">leading</a></b> (<i>self</i>)</li><li><div class="fn" />bool <b><a href="qtextline.html#leadingIncluded">leadingIncluded</a></b> (<i>self</i>)</li><li><div class="fn" />int <b><a href="qtextline.html#lineNumber">lineNumber</a></b> (<i>self</i>)</li><li><div class="fn" />QRectF <b><a href="qtextline.html#naturalTextRect">naturalTextRect</a></b> (<i>self</i>)</li><li><div class="fn" />float <b><a href="qtextline.html#naturalTextWidth">naturalTextWidth</a></b> (<i>self</i>)</li><li><div class="fn" />QPointF <b><a href="qtextline.html#position">position</a></b> (<i>self</i>)</li><li><div class="fn" />QRectF <b><a href="qtextline.html#rect">rect</a></b> (<i>self</i>)</li><li><div class="fn" /><b><a href="qtextline.html#setLeadingIncluded">setLeadingIncluded</a></b> (<i>self</i>, bool&#160;<i>included</i>)</li><li><div class="fn" /><b><a href="qtextline.html#setLineWidth">setLineWidth</a></b> (<i>self</i>, float&#160;<i>width</i>)</li><li><div class="fn" /><b><a href="qtextline.html#setNumColumns">setNumColumns</a></b> (<i>self</i>, int&#160;<i>columns</i>)</li><li><div class="fn" /><b><a href="qtextline.html#setNumColumns-2">setNumColumns</a></b> (<i>self</i>, int&#160;<i>columns</i>, float&#160;<i>alignmentWidth</i>)</li><li><div class="fn" /><b><a href="qtextline.html#setPosition">setPosition</a></b> (<i>self</i>, QPointF&#160;<i>pos</i>)</li><li><div class="fn" />int <b><a href="qtextline.html#textLength">textLength</a></b> (<i>self</i>)</li><li><div class="fn" />int <b><a href="qtextline.html#textStart">textStart</a></b> (<i>self</i>)</li><li><div class="fn" />float <b><a href="qtextline.html#width">width</a></b> (<i>self</i>)</li><li><div class="fn" />float <b><a href="qtextline.html#x">x</a></b> (<i>self</i>)</li><li><div class="fn" />int <b><a href="qtextline.html#xToCursor">xToCursor</a></b> (<i>self</i>, float&#160;<i>x</i>, CursorPosition&#160;<i>edge</i>&#160;=&#160;QTextLine.CursorBetweenCharacters)</li><li><div class="fn" />float <b><a href="qtextline.html#y">y</a></b> (<i>self</i>)</li></ul><a name="details" /><hr /><h2>Detailed Description</h2><p>The QTextLine class represents a line of text inside a <a href="qtextlayout.html">QTextLayout</a>.</p>
<p>A text line is usually created by <a href="qtextlayout.html#createLine">QTextLayout.createLine</a>().</p>
<p>After being created, the line can be filled using the <a href="qtextline.html#setLineWidth">setLineWidth</a>() or <a href="qtextline.html#setNumColumns">setNumColumns</a>() functions. A
line has a number of attributes including the rectangle it
occupies, <a href="qtextline.html#rect">rect</a>(), its
coordinates, <a href="qtextline.html#x">x</a>() and <a href="qtextline.html#y">y</a>(), its <a href="qtextline.html#textLength">textLength</a>(), <a href="qtextline.html#width">width</a>() and <a href="qtextline.html#naturalTextWidth">naturalTextWidth</a>(), and its
<a href="qtextline.html#ascent">ascent</a>() and decent() relative
to the text. The position of the cursor in terms of the line is
available from <a href="qtextline.html#cursorToX">cursorToX</a>()
and its inverse from <a href="qtextline.html#xToCursor">xToCursor</a>(). A line can be moved
with <a href="qtextline.html#setPosition">setPosition</a>().</p>
<hr /><h2>Type Documentation</h2><h3 class="fn"><a name="CursorPosition-enum" />QTextLine.CursorPosition</h3><table class="valuelist">
<tr>
<th class="tblConst">Constant</th>
<th class="tblVal">Value</th>
</tr>
<tr>
<td class="topAlign">
<tt>QTextLine.CursorBetweenCharacters</tt></td>
<td class="topAlign"><tt>0</tt></td>
</tr>
<tr>
<td class="topAlign"><tt>QTextLine.CursorOnCharacter</tt></td>
<td class="topAlign"><tt>1</tt></td>
</tr>
</table>


<h3 class="fn"><a name="Edge-enum" />QTextLine.Edge</h3><table class="valuelist">
<tr>
<th class="tblConst">Constant</th>
<th class="tblVal">Value</th>
</tr>
<tr>
<td class="topAlign"><tt>QTextLine.Leading</tt></td>
<td class="topAlign"><tt>0</tt></td>
</tr>
<tr>
<td class="topAlign"><tt>QTextLine.Trailing</tt></td>
<td class="topAlign"><tt>1</tt></td>
</tr>
</table>
<hr /><h2>Method Documentation</h2><h3 class="fn"><a name="QTextLine" />QTextLine.__init__ (<i>self</i>)</h3><p>Creates an invalid line.</p>


<h3 class="fn"><a name="QTextLine-2" />QTextLine.__init__ (<i>self</i>, <a href="qtextline.html">QTextLine</a>)</h3><h3 class="fn"><a name="ascent" />float QTextLine.ascent (<i>self</i>)</h3><p>Returns the line's ascent.</p>
<p><b>See also</b> <a href="qtextline.html#descent">descent</a>()
and <a href="qtextline.html#height">height</a>().</p>


<h3 class="fn"><a name="cursorToX" />(float, int&#160;<i>cursorPos</i>) QTextLine.cursorToX (<i>self</i>, int&#160;<i>cursorPos</i>, <a href="qtextline.html#Edge-enum">Edge</a>&#160;<i>edge</i>&#160;=&#160;QTextLine.Leading)</h3><p>Converts the cursor position <i>cursorPos</i> to the
corresponding x position inside the line, taking account of the
<i>edge</i>.</p>
<p>If <i>cursorPos</i> is not a valid cursor position, the nearest
valid cursor position will be used instead, and cpos will be
modified to point to this valid cursor position.</p>
<p><b>See also</b> <a href="qtextline.html#xToCursor">xToCursor</a>().</p>


<h3 class="fn"><a name="descent" />float QTextLine.descent (<i>self</i>)</h3><p>Returns the line's descent.</p>
<p><b>See also</b> <a href="qtextline.html#ascent">ascent</a>() and
<a href="qtextline.html#height">height</a>().</p>


<h3 class="fn"><a name="draw" />QTextLine.draw (<i>self</i>, <a href="qpainter.html">QPainter</a>&#160;<i>painter</i>, <a href="qpointf.html">QPointF</a>&#160;<i>position</i>, <a href="qtextlayout-formatrange.html">QTextLayout.FormatRange</a>&#160;<i>selection</i>&#160;=&#160;None)</h3><p>Draws a line on the given <i>painter</i> at the specified
<i>position</i>. The <i>selection</i> is reserved for internal
use.</p>


<h3 class="fn"><a name="height" />float QTextLine.height (<i>self</i>)</h3><p>Returns the line's height. This is equal to <a href="qtextline.html#ascent">ascent</a>() + <a href="qtextline.html#descent">descent</a>() + 1 if leading is not
included. If leading is included, this equals to <a href="qtextline.html#ascent">ascent</a>() + <a href="qtextline.html#descent">descent</a>() + <a href="qtextline.html#leading">leading</a>() + 1.</p>
<p><b>See also</b> <a href="qtextline.html#ascent">ascent</a>(),
<a href="qtextline.html#descent">descent</a>(), <a href="qtextline.html#leading">leading</a>(), and <a href="qtextline.html#setLeadingIncluded">setLeadingIncluded</a>().</p>


<h3 class="fn"><a name="horizontalAdvance" />float QTextLine.horizontalAdvance (<i>self</i>)</h3><p>Returns the horizontal advance of the text. The advance of the
text is the distance from its position to the next position at
which text would naturally be drawn.</p>
<p>By adding the advance to the position of the text line and using
this as the position of a second text line, you will be able to
position the two lines side-by-side without gaps in-between.</p>
<p>This function was introduced in Qt 4.7.</p>


<h3 class="fn"><a name="isValid" />bool QTextLine.isValid (<i>self</i>)</h3><p>Returns true if this text line is valid; otherwise returns
false.</p>


<h3 class="fn"><a name="leading" />float QTextLine.leading (<i>self</i>)</h3><p>Returns the line's leading.</p>
<p>This function was introduced in Qt 4.6.</p>
<p><b>See also</b> <a href="qtextline.html#ascent">ascent</a>(),
<a href="qtextline.html#descent">descent</a>(), and <a href="qtextline.html#height">height</a>().</p>


<h3 class="fn"><a name="leadingIncluded" />bool QTextLine.leadingIncluded (<i>self</i>)</h3><p>Returns true if positive leading is included into the line's
height; otherwise returns false.</p>
<p>By default, leading is not included.</p>
<p>This function was introduced in Qt 4.6.</p>
<p><b>See also</b> <a href="qtextline.html#setLeadingIncluded">setLeadingIncluded</a>().</p>


<h3 class="fn"><a name="lineNumber" />int QTextLine.lineNumber (<i>self</i>)</h3><p>Returns the position of the line in the text engine.</p>


<h3 class="fn"><a name="naturalTextRect" /><a href="qrectf.html">QRectF</a> QTextLine.naturalTextRect (<i>self</i>)</h3><p>Returns the rectangle covered by the line.</p>


<h3 class="fn"><a name="naturalTextWidth" />float QTextLine.naturalTextWidth (<i>self</i>)</h3><p>Returns the width of the line that is occupied by text. This is
always &lt;= to <a href="qtextline.html#width">width</a>(), and is
the minimum width that could be used by layout() without changing
the line break position.</p>


<h3 class="fn"><a name="position" /><a href="qpointf.html">QPointF</a> QTextLine.position (<i>self</i>)</h3><p>Returns the line's position relative to the text layout's
position.</p>
<p><b>See also</b> <a href="qtextline.html#setPosition">setPosition</a>().</p>


<h3 class="fn"><a name="rect" /><a href="qrectf.html">QRectF</a> QTextLine.rect (<i>self</i>)</h3><p>Returns the line's bounding rectangle.</p>
<p><b>See also</b> <a href="qtextline.html#x">x</a>(), <a href="qtextline.html#y">y</a>(), <a href="qtextline.html#textLength">textLength</a>(), and <a href="qtextline.html#width">width</a>().</p>


<h3 class="fn"><a name="setLeadingIncluded" />QTextLine.setLeadingIncluded (<i>self</i>, bool&#160;<i>included</i>)</h3><p>Includes positive leading into the line's height if
<i>included</i> is true; otherwise does not include leading.</p>
<p>By default, leading is not included.</p>
<p>Note that negative leading is ignored, it must be handled in the
code using the text lines by letting the lines overlap.</p>
<p>This function was introduced in Qt 4.6.</p>
<p><b>See also</b> <a href="qtextline.html#leadingIncluded">leadingIncluded</a>().</p>


<h3 class="fn"><a name="setLineWidth" />QTextLine.setLineWidth (<i>self</i>, float&#160;<i>width</i>)</h3><p>Lays out the line with the given <i>width</i>. The line is
filled from its starting position with as many characters as will
fit into the line. In case the text cannot be split at the end of
the line, it will be filled with additional characters to the next
whitespace or end of the text.</p>


<h3 class="fn"><a name="setNumColumns" />QTextLine.setNumColumns (<i>self</i>, int&#160;<i>columns</i>)</h3><p>Lays out the line. The line is filled from its starting position
with as many characters as are specified by <i>numColumns</i>. In
case the text cannot be split until <i>numColumns</i> characters,
the line will be filled with as many characters to the next
whitespace or end of the text.</p>


<h3 class="fn"><a name="setNumColumns-2" />QTextLine.setNumColumns (<i>self</i>, int&#160;<i>columns</i>, float&#160;<i>alignmentWidth</i>)</h3><p>Lays out the line. The line is filled from its starting position
with as many characters as are specified by <i>numColumns</i>. In
case the text cannot be split until <i>numColumns</i> characters,
the line will be filled with as many characters to the next
whitespace or end of the text. The provided <i>alignmentWidth</i>
is used as reference width for alignment.</p>


<h3 class="fn"><a name="setPosition" />QTextLine.setPosition (<i>self</i>, <a href="qpointf.html">QPointF</a>&#160;<i>pos</i>)</h3><p>Moves the line to position <i>pos</i>.</p>
<p><b>See also</b> <a href="qtextline.html#position">position</a>().</p>


<h3 class="fn"><a name="textLength" />int QTextLine.textLength (<i>self</i>)</h3><p>Returns the length of the text in the line.</p>
<p><b>See also</b> <a href="qtextline.html#naturalTextWidth">naturalTextWidth</a>().</p>


<h3 class="fn"><a name="textStart" />int QTextLine.textStart (<i>self</i>)</h3><p>Returns the start of the line from the beginning of the string
passed to the <a href="qtextlayout.html">QTextLayout</a>.</p>


<h3 class="fn"><a name="width" />float QTextLine.width (<i>self</i>)</h3><p>Returns the line's width as specified by the layout()
function.</p>
<p><b>See also</b> <a href="qtextline.html#naturalTextWidth">naturalTextWidth</a>(), <a href="qtextline.html#x">x</a>(), <a href="qtextline.html#y">y</a>(),
<a href="qtextline.html#textLength">textLength</a>(), and <a href="qtextline.html#rect">rect</a>().</p>


<h3 class="fn"><a name="x" />float QTextLine.x (<i>self</i>)</h3><p>Returns the line's x position.</p>
<p><b>See also</b> <a href="qtextline.html#rect">rect</a>(),
<a href="qtextline.html#y">y</a>(), <a href="qtextline.html#textLength">textLength</a>(), and <a href="qtextline.html#width">width</a>().</p>


<h3 class="fn"><a name="xToCursor" />int QTextLine.xToCursor (<i>self</i>, float&#160;<i>x</i>, <a href="qtextline.html#CursorPosition-enum">CursorPosition</a>&#160;<i>edge</i>&#160;=&#160;QTextLine.CursorBetweenCharacters)</h3><p>Converts the x-coordinate <i>x</i>, to the nearest matching
cursor position, depending on the cursor position type,
<i>cpos</i>.</p>
<p><b>See also</b> <a href="qtextline.html#cursorToX">cursorToX</a>().</p>


<h3 class="fn"><a name="y" />float QTextLine.y (<i>self</i>)</h3><p>Returns the line's y position.</p>
<p><b>See also</b> <a href="qtextline.html#x">x</a>(), <a href="qtextline.html#rect">rect</a>(), <a href="qtextline.html#textLength">textLength</a>(), and <a href="qtextline.html#width">width</a>().</p>
<address><hr /><div align="center"><table border="0" cellspacing="0" width="100%"><tr class="address"><td align="left" width="25%">PyQt&#160;4.12.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.qt.io">The Qt Company</a> 2015</td><td align="right" width="25%">Qt&#160;4.8.7</td></tr></table></div></address></body></html>