- class QGraphicsSimpleTextItem#
The
QGraphicsSimpleTextItem
class provides a simple text path item that you can add to aQGraphicsScene
. More…Synopsis#
Methods#
def
__init__()
def
font()
def
setFont()
def
setText()
def
text()
Note
This documentation may contain snippets that were automatically translated from C++ to Python. We always welcome contributions to the snippet translation. If you see an issue with the translation, you can also let us know by creating a ticket on https:/bugreports.qt.io/projects/PYSIDE
Detailed Description#
To set the item’s text, you can either pass a QString to
QGraphicsSimpleTextItem
‘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 default Qt::NoPen.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.- __init__([parent=None])#
- Parameters:
parent –
QGraphicsItem
Constructs a
QGraphicsSimpleTextItem
.parent
is passed toQGraphicsItem
‘s constructor.See also
- __init__(text[, parent=None])
- Parameters:
text – str
parent –
QGraphicsItem
Constructs a
QGraphicsSimpleTextItem
, usingtext
as the default plain text.parent
is passed toQGraphicsItem
‘s constructor.See also
Returns the font that is used to draw the item’s text.
See also
Sets the font that is used to draw the item’s text to
font
.See also
- 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 type QChar::LineSeparator will cause item to break the text into multiple lines.See also
- text()#
- Return type:
str
Returns the item’s text.
See also