QGraphicsLineItem 類

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

頭: #include <QGraphicsLineItem>
qmake: QT += widgets
Since: Qt 4.2
繼承: 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 .

要設置項的綫條,傳遞 QLineF to QGraphicsLineItem 's constructor, or call the setLine () 函數。 line () 函數返迴當前綫條。默認情況下,綫條為黑色具有 0 寬度,但可以改變這通過調用 setPen ().

QGraphicsLineItem uses the line and the pen width to provide a reasonable implementation of boundingRect (), shape (),和 contains ()。 paint () 函數使用項關聯的鋼筆繪製綫條。

另請參閱 QGraphicsPathItem , QGraphicsRectItem , QGraphicsEllipseItem , QGraphicsTextItem , QGraphicsPolygonItem , QGraphicsPixmapItem ,和 圖形視圖框架 .

成員類型文檔編製

enum QGraphicsLineItem:: anonymous

值的返迴是通過虛擬 type () 函數。

常量 描述
QGraphicsLineItem::Type 6 圖形綫條項

成員函數文檔編製

QGraphicsLineItem:: QGraphicsLineItem ( QGraphicsItem * parent = nullptr)

構造 QGraphicsLineItem . parent 被傳遞給 QGraphicsItem 的構造函數。

另請參閱 QGraphicsScene::addItem ().

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

構造 QGraphicsLineItem ,使用 line 作為默認綫條。 parent 被傳遞給 QGraphicsItem 的構造函數。

另請參閱 QGraphicsScene::addItem ().

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

構造 QGraphicsLineItem , using the line between ( x1 , y1 ) 和 ( x2 , y2 ) 作為默認綫條。 parent 被傳遞給 QGraphicsItem 的構造函數。

另請參閱 QGraphicsScene::addItem ().

[虛擬] QGraphicsLineItem:: ~QGraphicsLineItem ()

銷毀 QGraphicsLineItem .

[override virtual] QRectF QGraphicsLineItem:: boundingRect () const

重實現自 QGraphicsItem::boundingRect ().

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

重實現自 QGraphicsItem::contains ().

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

重實現自 QGraphicsItem::isObscuredBy ().

QLineF QGraphicsLineItem:: line () const

返迴項的綫條,或 null 綫條若未設置綫條。

另請參閱 setLine ().

[override virtual] QPainterPath QGraphicsLineItem:: opaqueArea () const

重實現自 QGraphicsItem::opaqueArea ().

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

重實現自 QGraphicsItem::paint ().

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 )

這是重載函數。

Sets the item's line to be the line between ( 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 ().

[override virtual] int QGraphicsLineItem:: type () const

重實現自 QGraphicsItem::type ().