QGraphicsSimpleTextItemclass provides a simple text path item that you can add to aQGraphicsScene. 更多 …
To set the item’s text, you can either pass a
QStringtoQGraphicsSimpleTextItem‘s constructor, or callsetText()to change the text later. To set the text fill color, callsetBrush().The simple text item can have both a fill and an outline;
setBrush()will set the text fill (i.e., text color), andsetPen()sets the pen that will be used to draw the text outline. (The latter can be slow, especially for complex pens, and items with long text content.) If all you want is to draw a simple line of text, you should callsetBrush()only, and leave the pen unset;QGraphicsSimpleTextItem‘s pen is by defaultNoPen.
QGraphicsSimpleTextItemuses the text’s formatted size and the associated font to provide a reasonable implementation ofboundingRect(),shape(),和contains(). You can set the font by callingsetFont().QGraphicsSimpleText 不显示富文本;相反,可使用
QGraphicsTextItem,其提供完整文本控制能力。![]()
QGraphicsSimpleTextItem
(
[
parent=None
]
)
¶
QGraphicsSimpleTextItem(text[, parent=None])
- param parent
- param text
unicode
parent
会被传递给
QGraphicsItem
‘s constructor.
另请参阅
构造
QGraphicsSimpleTextItem
,使用
text
作为默认纯文本。
parent
会被传递给
QGraphicsItem
‘s constructor.
另请参阅
PySide2.QtWidgets.QGraphicsSimpleTextItem.
font
(
)
¶
QFont
Returns the font that is used to draw the item’s text.
另请参阅
PySide2.QtWidgets.QGraphicsSimpleTextItem.
setFont
(
font
)
¶
font
–
QFont
Sets the font that is used to draw the item’s text to
font
.
另请参阅
PySide2.QtWidgets.QGraphicsSimpleTextItem.
setText
(
text
)
¶
text – unicode
Sets the item’s text to
text
. The text will be displayed as plain text. Newline characters (‘\n’) as well as characters of type
LineSeparator
will cause item to break the text into multiple lines.
另请参阅