QGraphicsSimpleTextItem Class Reference

[ QtGui module]

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

继承 QAbstractGraphicsShapeItem .

方法


详细描述

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

To set the item's text, you can either pass a QString to QGraphicsSimpleTextItem's constructor, or call setText () to change the text later. To set the text fill color, call setBrush ().

The simple text item can have both a fill and an outline; setBrush () will set the text fill (i.e., text color), and 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 setBrush () 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 of boundingRect (), shape (),和 contains (). You can set the font by calling setFont ().

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


方法文档编制

QGraphicsSimpleTextItem.__init__ ( self , QGraphicsItem   parent  = None, QGraphicsScene   scene  = None)

parent argument, if not None, causes self to be owned by Qt instead of PyQt.

scene argument, if not None, causes self to be owned by Qt instead of PyQt.

构造 QGraphicsSimpleTextItem .

parent 会被传递给 QGraphicsItem 的构造函数。

另请参阅 QGraphicsScene.addItem ().

QGraphicsSimpleTextItem.__init__ ( self , QString  text , QGraphicsItem   parent  = None, QGraphicsScene   scene  = None)

parent argument, if not None, causes self to be owned by Qt instead of PyQt.

scene argument, if not None, causes self to be owned by Qt instead of PyQt.

构造 QGraphicsSimpleTextItem ,使用 text 作为默认纯文本。

parent 会被传递给 QGraphicsItem 的构造函数。

另请参阅 QGraphicsScene.addItem ().

QRectF QGraphicsSimpleTextItem.boundingRect ( self )

重实现自 QGraphicsItem.boundingRect ().

bool QGraphicsSimpleTextItem.contains ( self , QPointF   point )

重实现自 QGraphicsItem.contains ().

QFont QGraphicsSimpleTextItem.font ( self )

返回用于绘制项文本的字体。

另请参阅 setFont ().

bool QGraphicsSimpleTextItem.isObscuredBy ( self , QGraphicsItem   item )

重实现自 QGraphicsItem.isObscuredBy ().

QPainterPath QGraphicsSimpleTextItem.opaqueArea ( self )

重实现自 QGraphicsItem.opaqueArea ().

QGraphicsSimpleTextItem.paint ( self , QPainter   painter , QStyleOptionGraphicsItem   option , QWidget   widget )

重实现自 QGraphicsItem.paint ().

QGraphicsSimpleTextItem.setFont ( self , QFont   font )

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

另请参阅 font ().

QGraphicsSimpleTextItem.setText ( self , QString  text )

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.

另请参阅 text ().

QPainterPath QGraphicsSimpleTextItem.shape ( self )

重实现自 QGraphicsItem.shape ().

QString QGraphicsSimpleTextItem.text ( self )

返回项的文本。

另请参阅 setText ().

int QGraphicsSimpleTextItem.type ( self )

重实现自 QGraphicsItem.type ().