QTextLineclass represents a line of text inside aQTextLayout. 更多 …
def
ascent
()
def
cursorToX
(cursorPos[, edge=Leading])
def
descent
()
def
draw
(p, point[, selection=None])
def
height
()
def
horizontalAdvance
()
def
isValid
()
def
leading
()
def
leadingIncluded
()
def
lineNumber
()
def
naturalTextRect
()
def
naturalTextWidth
()
def
position
()
def
rect
()
def
setLeadingIncluded
(included)
def
setLineWidth
(width)
def
setNumColumns
(columns)
def
setNumColumns
(columns, alignmentWidth)
def
setPosition
(pos)
def
textLength
()
def
textStart
()
def
width
()
def
x
()
def
xToCursor
(x[, edge=CursorBetweenCharacters])
def
y
()
A text line is usually created by
createLine().After being created, the line can be filled using the
setLineWidth()orsetNumColumns()functions. A line has a number of attributes including the rectangle it occupies,rect(), its coordinates,x()andy(), itstextLength(),width()andnaturalTextWidth(), and itsascent()anddescent()relative to the text. The position of the cursor in terms of the line is available fromcursorToX()and its inverse fromxToCursor(). A line can be moved withsetPosition().
QTextLine
¶
Creates an invalid line.
PySide2.QtGui.QTextLine.
Edge
¶
|
常量 |
描述 |
|---|---|
|
QTextLine.Leading |
|
|
QTextLine.Trailing |
PySide2.QtGui.QTextLine.
CursorPosition
¶
|
常量 |
描述 |
|---|---|
|
QTextLine.CursorBetweenCharacters |
|
|
QTextLine.CursorOnCharacter |
PySide2.QtGui.QTextLine.
ascent
(
)
¶
qreal
Returns the line’s ascent.
PySide2.QtGui.QTextLine.
cursorToX
(
cursorPos
[
,
edge=Leading
]
)
¶
cursorPos
–
int
edge
–
Edge
PyObject
这是重载函数。
PySide2.QtGui.QTextLine.
descent
(
)
¶
qreal
Returns the line’s descent.
PySide2.QtGui.QTextLine.
draw
(
p
,
point
[
,
selection=None
]
)
¶
p
–
QPainter
point
–
QPointF
selection
–
FormatRange
Draws a line on the given
painter
at the specified
position
。
selection
is reserved for internal use.
PySide2.QtGui.QTextLine.
height
(
)
¶
qreal
Returns the line’s height. This is equal to
ascent()
+
descent()
if leading is not included. If leading is included, this equals to
ascent()
+
descent()
+
leading()
.
PySide2.QtGui.QTextLine.
horizontalAdvance
(
)
¶
qreal
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.
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.
PySide2.QtGui.QTextLine.
isValid
(
)
¶
bool
返回
true
if this text line is valid; otherwise returns
false
.
PySide2.QtGui.QTextLine.
leading
(
)
¶
qreal
Returns the line’s leading.
PySide2.QtGui.QTextLine.
leadingIncluded
(
)
¶
bool
返回
true
if positive leading is included into the line’s height; otherwise returns
false
.
By default, leading is not included.
另请参阅
PySide2.QtGui.QTextLine.
lineNumber
(
)
¶
int
Returns the position of the line in the text engine.
PySide2.QtGui.QTextLine.
naturalTextRect
(
)
¶
QRectF
Returns the rectangle covered by the line.
PySide2.QtGui.QTextLine.
naturalTextWidth
(
)
¶
qreal
Returns the width of the line that is occupied by text. This is always <= to
width()
, and is the minimum width that could be used by layout() without changing the line break position.
PySide2.QtGui.QTextLine.
position
(
)
¶
QPointF
Returns the line’s position relative to the text layout’s position.
另请参阅
PySide2.QtGui.QTextLine.
rect
(
)
¶
QRectF
Returns the line’s bounding rectangle.
另请参阅
PySide2.QtGui.QTextLine.
setLeadingIncluded
(
included
)
¶
included
–
bool
Includes positive leading into the line’s height if
included
is true; otherwise does not include leading.
By default, leading is not included.
Note that negative leading is ignored, it must be handled in the code using the text lines by letting the lines overlap.
另请参阅
PySide2.QtGui.QTextLine.
setLineWidth
(
width
)
¶
width
–
qreal
Lays out the line with the given
width
. 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.
PySide2.QtGui.QTextLine.
setNumColumns
(
columns
)
¶
columns
–
int
Lays out the line. The line is filled from its starting position with as many characters as are specified by
numColumns
. In case the text cannot be split until
numColumns
characters, the line will be filled with as many characters to the next whitespace or end of the text.
PySide2.QtGui.QTextLine.
setNumColumns
(
columns
,
alignmentWidth
)
¶
columns
–
int
alignmentWidth
–
qreal
Lays out the line. The line is filled from its starting position with as many characters as are specified by
numColumns
. In case the text cannot be split until
numColumns
characters, the line will be filled with as many characters to the next whitespace or end of the text. The provided
alignmentWidth
is used as reference width for alignment.
PySide2.QtGui.QTextLine.
setPosition
(
pos
)
¶
pos
–
QPointF
Moves the line to position
pos
.
另请参阅
PySide2.QtGui.QTextLine.
textLength
(
)
¶
int
Returns the length of the text in the line.
另请参阅
PySide2.QtGui.QTextLine.
textStart
(
)
¶
int
Returns the start of the line from the beginning of the string passed to the
QTextLayout
.
PySide2.QtGui.QTextLine.
width
(
)
¶
qreal
Returns the line’s width as specified by the layout() function.
PySide2.QtGui.QTextLine.
x
(
)
¶
qreal
Returns the line’s x position.
另请参阅
PySide2.QtGui.QTextLine.
xToCursor
(
x
[
,
edge=CursorBetweenCharacters
]
)
¶
x
–
qreal
edge
–
CursorPosition
int
Converts the x-coordinate
x
, to the nearest matching cursor position, depending on the cursor position type,
cpos
. Note that result cursor position includes possible preedit area text.
另请参阅
PySide2.QtGui.QTextLine.
y
(
)
¶
qreal
Returns the line’s y position.
另请参阅