QGraphicsSimpleTextItem¶
The
QGraphicsSimpleTextItem
class provides a simple text path item that you can add to aQGraphicsScene
. More…
Synopsis¶
Functions¶
Detailed Description¶
To set the item’s text, you can either pass a
QString
toQGraphicsSimpleTextItem
‘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
.
QGraphicsSimpleTextItem
uses the text’s formatted size and the associated font to provide a reasonable implementation ofboundingRect()
,shape()
, andcontains()
. You can set the font by callingsetFont()
.QGraphicsSimpleText does not display rich text; instead, you can use
QGraphicsTextItem
, which provides full text control capabilities.
- class PySide2.QtWidgets.QGraphicsSimpleTextItem([parent=None])¶
PySide2.QtWidgets.QGraphicsSimpleTextItem(text[, parent=None])
- param parent:
- param text:
str
Constructs a
QGraphicsSimpleTextItem
.parent
is passed toQGraphicsItem
‘s constructor.See also
Constructs a
QGraphicsSimpleTextItem
, usingtext
as the default plain text.parent
is passed toQGraphicsItem
‘s constructor.See also
- PySide2.QtWidgets.QGraphicsSimpleTextItem.font()¶
- Return type:
Returns the font that is used to draw the item’s text.
See also
- PySide2.QtWidgets.QGraphicsSimpleTextItem.setFont(font)¶
- Parameters:
font –
PySide2.QtGui.QFont
Sets the font that is used to draw the item’s text to
font
.See also
- PySide2.QtWidgets.QGraphicsSimpleTextItem.setText(text)¶
- Parameters:
text – str
Sets the item’s text to
text
. The text will be displayed as plain text. Newline characters (’\n’) as well as characters of typeLineSeparator
will cause item to break the text into multiple lines.See also
© 2022 The Qt Company Ltd. Documentation contributions included herein are the copyrights of their respective owners. The documentation provided herein is licensed under the terms of the GNU Free Documentation License version 1.3 as published by the Free Software Foundation. Qt and respective logos are trademarks of The Qt Company Ltd. in Finland and/or other countries worldwide. All other trademarks are property of their respective owners.