QGraphicsLineItem Class

The QGraphicsLineItem class provides a line item that you can add to a QGraphicsScene. 更多...

头文件: #include <QGraphicsLineItem>
qmake: QT += widgets
开始支持版本: Qt 4.2
基类: QGraphicsItem

公有函数

QGraphicsLineItem(QGraphicsItem *parent = Q_NULLPTR)
QGraphicsLineItem(const QLineF &line, QGraphicsItem *parent = Q_NULLPTR)
QGraphicsLineItem(qreal x1, qreal y1, qreal x2, qreal y2, QGraphicsItem *parent = Q_NULLPTR)
~QGraphicsLineItem()
QLineF line() const
QPen pen() const
void setLine(const QLineF &line)
void setLine(qreal x1, qreal y1, qreal x2, qreal y2)
void setPen(const QPen &pen)

重新实现的公有函数

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 = Q_NULLPTR)
virtual QPainterPath shape() const
virtual int type() const

其他继承的成员

详细描述

The QGraphicsLineItem class provides a line item that you can add to a QGraphicsScene.

To set the item's line, pass a QLineF to QGraphicsLineItem's constructor, or call the setLine() function. The line() function returns the current line. By default the line is black with a width of 0, but you can change this by calling setPen().

QGraphicsLineItem uses the line and the pen width to provide a reasonable implementation of boundingRect(), shape(), and contains(). The paint() function draws the line using the item's associated pen.

参见 QGraphicsPathItem, QGraphicsRectItem, QGraphicsEllipseItem, QGraphicsTextItem, QGraphicsPolygonItem, QGraphicsPixmapItem, and Graphics View Framework.

成员函数

QGraphicsLineItem::QGraphicsLineItem(QGraphicsItem *parent = Q_NULLPTR)

Constructs a QGraphicsLineItem. parent is passed to QGraphicsItem's constructor.

参见 QGraphicsScene::addItem().

QGraphicsLineItem::QGraphicsLineItem(const QLineF &line, QGraphicsItem *parent = Q_NULLPTR)

Constructs a QGraphicsLineItem, using line as the default line. parent is passed to QGraphicsItem's constructor.

参见 QGraphicsScene::addItem().

QGraphicsLineItem::QGraphicsLineItem(qreal x1, qreal y1, qreal x2, qreal y2, QGraphicsItem *parent = Q_NULLPTR)

Constructs a QGraphicsLineItem, using the line between (x1, y1) and (x2, y2) as the default line. parent is passed to QGraphicsItem's constructor.

参见 QGraphicsScene::addItem().

QGraphicsLineItem::~QGraphicsLineItem()

Destroys the QGraphicsLineItem.

[virtual] QRectF QGraphicsLineItem::boundingRect() const

重新实现 QGraphicsItem::boundingRect().

[virtual] bool QGraphicsLineItem::contains(const QPointF &point) const

重新实现 QGraphicsItem::contains().

[virtual] bool QGraphicsLineItem::isObscuredBy(const QGraphicsItem *item) const

重新实现 QGraphicsItem::isObscuredBy().

QLineF QGraphicsLineItem::line() const

Returns the item's line, or a null line if no line has been set.

参见 setLine().

[virtual] QPainterPath QGraphicsLineItem::opaqueArea() const

重新实现 QGraphicsItem::opaqueArea().

[virtual] void QGraphicsLineItem::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget = Q_NULLPTR)

重新实现 QGraphicsItem::paint().

QPen QGraphicsLineItem::pen() const

Returns the item's pen, or a black solid 0-width pen if no pen has been set.

参见 setPen().

void QGraphicsLineItem::setLine(const QLineF &line)

Sets the item's line to be the given line.

参见 line().

void QGraphicsLineItem::setLine(qreal x1, qreal y1, qreal x2, qreal y2)

This is an overloaded function.

Sets the item's line to be the line between (x1, y1) and (x2, y2).

This is the same as calling setLine(QLineF(x1, y1, x2, y2)).

void QGraphicsLineItem::setPen(const QPen &pen)

Sets the item's pen to pen. If no pen is set, the line will be painted using a black solid 0-width pen.

参见 pen().

[virtual] QPainterPath QGraphicsLineItem::shape() const

重新实现 QGraphicsItem::shape().

[virtual] int QGraphicsLineItem::type() const

重新实现 QGraphicsItem::type().