The QGraphicsLineItem class provides a line item that you can add to a QGraphicsScene. More...
Header: | #include <QGraphicsLineItem> |
qmake: | QT += widgets |
Since: | Qt 4.2 |
Inherits: | QGraphicsItem |
enum | anonymous { Type } |
QGraphicsLineItem(QGraphicsItem *parent = nullptr) | |
QGraphicsLineItem(const QLineF &line, QGraphicsItem *parent = nullptr) | |
QGraphicsLineItem(qreal x1, qreal y1, qreal x2, qreal y2, QGraphicsItem *parent = nullptr) | |
virtual | ~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 override |
virtual bool | contains(const QPointF &point) const override |
virtual bool | isObscuredBy(const QGraphicsItem *item) const override |
virtual QPainterPath | opaqueArea() const override |
virtual void | paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget = nullptr) override |
virtual QPainterPath | shape() const override |
virtual int | type() const override |
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.
See also QGraphicsPathItem, QGraphicsRectItem, QGraphicsEllipseItem, QGraphicsTextItem, QGraphicsPolygonItem, QGraphicsPixmapItem, and Graphics View Framework.
The value returned by the virtual type() function.
Constant | Value | Description |
---|---|---|
QGraphicsLineItem::Type |
6 |
A graphics line item |
Constructs a QGraphicsLineItem. parent is passed to QGraphicsItem's constructor.
See also QGraphicsScene::addItem().
Constructs a QGraphicsLineItem, using line as the default line. parent is passed to QGraphicsItem's constructor.
See also QGraphicsScene::addItem().
Constructs a QGraphicsLineItem, using the line between (x1, y1) and (x2, y2) as the default line. parent is passed to QGraphicsItem's constructor.
See also QGraphicsScene::addItem().
[virtual]
QGraphicsLineItem::~QGraphicsLineItem()Destroys the QGraphicsLineItem.
[override virtual]
QRectF QGraphicsLineItem::boundingRect() constReimplemented from QGraphicsItem::boundingRect().
[override virtual]
bool QGraphicsLineItem::contains(const QPointF &point) constReimplemented from QGraphicsItem::contains().
[override virtual]
bool QGraphicsLineItem::isObscuredBy(const QGraphicsItem *item) constReimplemented from QGraphicsItem::isObscuredBy().
Returns the item's line, or a null line if no line has been set.
See also setLine().
[override virtual]
QPainterPath QGraphicsLineItem::opaqueArea() constReimplemented from QGraphicsItem::opaqueArea().
[override virtual]
void QGraphicsLineItem::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget = nullptr)Reimplemented from QGraphicsItem::paint().
Returns the item's pen, or a black solid 0-width pen if no pen has been set.
See also setPen().
Sets the item's line to be the given line.
See also line().
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))
.
Sets the item's pen to pen. If no pen is set, the line will be painted using a black solid 0-width pen.
See also pen().
[override virtual]
QPainterPath QGraphicsLineItem::shape() constReimplemented from QGraphicsItem::shape().
[override virtual]
int QGraphicsLineItem::type() constReimplemented from QGraphicsItem::type().