QGraphicsLineItem 類提供的綫條項可以添加到 QGraphicsScene . 更多...
| 頭: | #include <QGraphicsLineItem> |
| qmake: | QT += widgets |
| Since: | Qt 4.2 |
| 繼承: | QGraphicsItem |
該類在 Qt 4.2 引入。
| enum | anonymous { Type } |
| QGraphicsLineItem (qreal x1 , qreal y1 , qreal x2 , qreal y2 , QGraphicsItem * parent = nullptr) | |
| QGraphicsLineItem (const QLineF & line , QGraphicsItem * parent = nullptr) | |
| QGraphicsLineItem (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 ,和 圖形視圖框架 .
值的返迴是通過虛擬 type () 函數。
| 常量 | 值 | 描述 |
|---|---|---|
QGraphicsLineItem::Type
|
6
|
圖形綫條項 |
構造 QGraphicsLineItem,使用綫條介於 ( x1 , y1 ) 和 ( x2 , y2 ) 作為默認綫條。 parent 被傳遞給 QGraphicsItem 的構造函數。
另請參閱 QGraphicsScene::addItem ().
構造 QGraphicsLineItem,使用 line 作為默認綫條。 parent 被傳遞給 QGraphicsItem 的構造函數。
另請參閱 QGraphicsScene::addItem ().
構造 QGraphicsLineItem。 parent 被傳遞給 QGraphicsItem 的構造函數。
另請參閱 QGraphicsScene::addItem ().
[虛擬]
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.
返迴項的綫條,或 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).
返迴項的鋼筆,或黑色 0 寬度實綫鋼筆若未設置鋼筆。
另請參閱 setPen ().
將項的綫條設為給定 line .
另請參閱 line ().
這是重載函數。
Sets the item's line to be the line between ( x1 , y1 ) 和 ( x2 , y2 ).
這如同調用
setLine(QLineF(x1, y1, x2, y2))
.
將項的鋼筆設為 pen 。若未設置鋼筆,將使用黑色 0 寬度實綫鋼筆繪製綫條。
另請參閱 pen ().
[override virtual]
QPainterPath
QGraphicsLineItem::
shape
() const
重實現: QGraphicsItem::shape () const.
[override virtual]
int
QGraphicsLineItem::
type
() const
重實現: QGraphicsItem::type () const.