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 | 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 |
詳細説明
アイテムの行を設定するには、QLineF を QGraphicsLineItem のコンストラクタに渡すか、setLine() 関数を呼び出します。line() 関数は現在の行を返します。デフォルトでは、線の幅は 0 で黒ですが、setPen() を呼び出すことで変更できます。
QGraphicsLineItem は、線とペンの幅を使用して、boundingRect()、shape()、contains() の妥当な実装を提供します。paint() 関数は、アイテムに関連付けられたペンを使用して線を描画します。
QGraphicsPathItem,QGraphicsRectItem,QGraphicsEllipseItem,QGraphicsTextItem,QGraphicsPolygonItem,QGraphicsPixmapItem, およびGraphics View Frameworkも参照のこと 。
メンバ型ドキュメント
enum QGraphicsLineItem::anonymous
仮想type() 関数が返す値。
定数 | 値 | 説明 |
---|---|---|
QGraphicsLineItem::Type | 6 | グラフィックラインアイテム |
メンバ関数ドキュメント
[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.
© 2025 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.