QGraphicsLineItem Class
QGraphicsLineItem クラスは、QGraphicsScene に追加できる線アイテムを提供します。詳細...
| ヘッダー: | #include <QGraphicsLineItem> |
| CMake: | find_package(Qt6 REQUIRED COMPONENTS Widgets) target_link_libraries(mytarget PRIVATE Qt6::Widgets) |
| qmake: | QT += widgets |
| 継承元: | QGraphicsItem |
パブリック型
| enum { 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 |
詳細な説明
アイテムの線を設定するには、QLineF をQGraphicsLineItemのコンストラクタに渡し、またはsetLine()関数を呼び出します。line()関数は、現在の線を返します。デフォルトでは、線は黒で幅は0ですが、setPen()を呼び出すことでこれを変更できます。

QGraphicsLineItemは、線とペンの幅を使用して、boundingRect()、shape()、およびcontains()の適切な実装を提供します。paint()関数は、アイテムに関連付けられたペンを使用して線を描画します。
関連項目: QGraphicsPathItem 、QGraphicsRectItem 、QGraphicsEllipseItem 、QGraphicsTextItem 、QGraphicsPolygonItem 、QGraphicsPixmapItem 、およびGraphics View Framework。
メンバ関数のドキュメント
[explicit] QGraphicsLineItem::QGraphicsLineItem(QGraphicsItem *parent = nullptr)
QGraphicsLineItem を作成します。parent は、QGraphicsItem のコンストラクタに渡されます。
QGraphicsScene::addItem()も参照してください 。
[explicit] QGraphicsLineItem::QGraphicsLineItem(const QLineF &line, QGraphicsItem *parent = nullptr)
line をデフォルトの線として使用し、QGraphicsLineItemを生成します。parent は、QGraphicsItem のコンストラクタに渡されます。
QGraphicsScene::addItem()も参照してください 。
[explicit] QGraphicsLineItem::QGraphicsLineItem(qreal x1, qreal y1, qreal x2, qreal y2, QGraphicsItem *parent = nullptr)
(x1,y1) と (x2,y2) の間の直線をデフォルトの直線として、QGraphicsLineItem を作成します。parent は、QGraphicsItem のコンストラクタに渡されます。
QGraphicsScene::addItem()も参照してください 。
[virtual noexcept] QGraphicsLineItem::~QGraphicsLineItem()
QGraphicsLineItem を削除します。
[override virtual] QRectF QGraphicsLineItem::boundingRect() const
QGraphicsItem::boundingRect() const を再実装します。
[override virtual] bool QGraphicsLineItem::contains(const QPointF &point) const
QGraphicsItem::contains (const QPointF &point)const を再実装します。
[override virtual] bool QGraphicsLineItem::isObscuredBy(const QGraphicsItem *item) const
QGraphicsItem::isObscuredBy (const QGraphicsItem *item)const の再実装です。
QLineF QGraphicsLineItem::line() const
アイテムの行を返します。行が設定されていない場合は、null行を返します。
setLine()も参照してください 。
[override virtual] QPainterPath QGraphicsLineItem::opaqueArea() const
QGraphicsItem::opaqueArea() const を再実装します。
[override virtual] void QGraphicsLineItem::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget = nullptr)
QGraphicsItem::paint (QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget)を再実装します。
QPen QGraphicsLineItem::pen() const
アイテムのペンを返します。ペンが設定されていない場合は、幅0の黒一色のペンを返します。
setPen()も参照してください 。
void QGraphicsLineItem::setLine(const QLineF &line)
アイテムの線を、指定されたline に設定します。
line()も参照してください 。
void QGraphicsLineItem::setLine(qreal x1, qreal y1, qreal x2, qreal y2)
アイテムの線を、(x1,y1) と (x2,y2) の間の線に設定します。
これは、setLine(QLineF(x1, y1, x2, y2)) を呼び出すのと同じです。
これはオーバーロードされた関数です。
void QGraphicsLineItem::setPen(const QPen &pen)
アイテムのペンを `pen` に設定します。ペンが設定されていない場合、線は幅0の黒一色のペンで描画されます。
pen()も参照してください 。
[override virtual] QPainterPath QGraphicsLineItem::shape() const
QGraphicsItem::shape() const を再実装します。
[override virtual] int QGraphicsLineItem::type() const
QGraphicsItem::type() const を再実装します。
© 2026 The Qt Company Ltd. Documentation contributions included herein are the copyrights of their respective owners. The documentation provided herein is licensed under the terms of the GNU Free Documentation License version 1.3 as published by the Free Software Foundation. Qt and respective logos are trademarks of The Qt Company Ltd. in Finland and/or other countries worldwide. All other trademarks are property of their respective owners.