Inheritance diagram of QGraphicsSimpleTextItem



Detailed Description

The PySide.QtGui.QGraphicsSimpleTextItem class provides a simple text path item that you can add to a PySide.QtGui.QGraphicsScene .

To set the item’s text, you can either pass a PySide.QtCore.QString to PySide.QtGui.QGraphicsSimpleTextItem ‘s constructor, or call PySide.QtGui.QGraphicsSimpleTextItem.setText() to change the text later. To set the text fill color, call PySide.QtGui.QAbstractGraphicsShapeItem.setBrush() .

The simple text item can have both a fill and an outline; PySide.QtGui.QAbstractGraphicsShapeItem.setBrush() will set the text fill (i.e., text color), and PySide.QtGui.QAbstractGraphicsShapeItem.setPen() 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 call PySide.QtGui.QAbstractGraphicsShapeItem.setBrush() only, and leave the pen unset; PySide.QtGui.QGraphicsSimpleTextItem ‘s pen is by default Qt.NoPen .

PySide.QtGui.QGraphicsSimpleTextItem uses the text’s formatted size and the associated font to provide a reasonable implementation of PySide.QtGui.QGraphicsSimpleTextItem.boundingRect() , PySide.QtGui.QGraphicsSimpleTextItem.shape() , and PySide.QtGui.QGraphicsSimpleTextItem.contains() . You can set the font by calling PySide.QtGui.QGraphicsSimpleTextItem.setFont() .

QGraphicsSimpleText does not display rich text; instead, you can use PySide.QtGui.QGraphicsTextItem , which provides full text control capabilities.

class PySide.QtGui.QGraphicsSimpleTextItem([parent=None[, scene=None]])
class PySide.QtGui.QGraphicsSimpleTextItem(text[, parent=None[, scene=None]])
Return type:PySide.QtGui.QFont

Returns the font that is used to draw the item’s text.


Sets the font that is used to draw the item’s text to font .

Parameters: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 QChar.LineSeparator will cause item to break the text into multiple lines.

Return type:unicode

Returns the item’s text.