QGraphicsSimpleTextItem Class
The QGraphicsSimpleTextItem class provides a simple text path item that you can add to a QGraphicsScene. 更多...
头文件: | #include <QGraphicsSimpleTextItem> |
qmake: | QT += widgets |
开始支持版本: | Qt 4.2 |
基类: | QAbstractGraphicsShapeItem |
公有函数
QGraphicsSimpleTextItem(QGraphicsItem *parent = Q_NULLPTR) | |
QGraphicsSimpleTextItem(const QString &text, QGraphicsItem *parent = Q_NULLPTR) | |
~QGraphicsSimpleTextItem() | |
QFont | font() const |
void | setFont(const QFont &font) |
void | setText(const QString &text) |
QString | text() const |
重新实现的公有函数
virtual QRectF | boundingRect() const |
virtual bool | contains(const QPointF &point) const |
virtual bool | isObscuredBy(const QGraphicsItem *item) const |
virtual QPainterPath | opaqueArea() const |
virtual void | paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget) |
virtual QPainterPath | shape() const |
virtual int | type() const |
- 6 个公有函数继承自 QAbstractGraphicsShapeItem
- 176 个公有函数继承自 QGraphicsItem
其他继承的成员
- 2 个静态公有成员继承自 QGraphicsItem
- 24 个受保护的函数继承自 QGraphicsItem
详细描述
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(), and 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.
参见 QGraphicsTextItem, QGraphicsPathItem, QGraphicsRectItem, QGraphicsEllipseItem, QGraphicsPixmapItem, QGraphicsPolygonItem, QGraphicsLineItem, and Graphics View Framework.
成员函数
QGraphicsSimpleTextItem::QGraphicsSimpleTextItem(QGraphicsItem *parent = Q_NULLPTR)
Constructs a QGraphicsSimpleTextItem.
parent is passed to QGraphicsItem's constructor.
参见 QGraphicsScene::addItem().
QGraphicsSimpleTextItem::QGraphicsSimpleTextItem(const QString &text, QGraphicsItem *parent = Q_NULLPTR)
Constructs a QGraphicsSimpleTextItem, using text as the default plain text.
parent is passed to QGraphicsItem's constructor.
参见 QGraphicsScene::addItem().
QGraphicsSimpleTextItem::~QGraphicsSimpleTextItem()
Destroys the QGraphicsSimpleTextItem.
[virtual]
QRectF QGraphicsSimpleTextItem::boundingRect() const
重新实现 QGraphicsItem::boundingRect().
[virtual]
bool QGraphicsSimpleTextItem::contains(const QPointF &point) const
重新实现 QGraphicsItem::contains().
QFont QGraphicsSimpleTextItem::font() const
Returns the font that is used to draw the item's text.
参见 setFont().
[virtual]
bool QGraphicsSimpleTextItem::isObscuredBy(const QGraphicsItem *item) const
重新实现 QGraphicsItem::isObscuredBy().
[virtual]
QPainterPath QGraphicsSimpleTextItem::opaqueArea() const
重新实现 QGraphicsItem::opaqueArea().
[virtual]
void QGraphicsSimpleTextItem::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget)
重新实现 QGraphicsItem::paint().
void QGraphicsSimpleTextItem::setFont(const QFont &font)
Sets the font that is used to draw the item's text to font.
参见 font().
void QGraphicsSimpleTextItem::setText(const 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().
[virtual]
QPainterPath QGraphicsSimpleTextItem::shape() const
重新实现 QGraphicsItem::shape().
QString QGraphicsSimpleTextItem::text() const
Returns the item's text.
参见 setText().
[virtual]
int QGraphicsSimpleTextItem::type() const
重新实现 QGraphicsItem::type().