QGraphicsLineItem 类

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

头: #include <QGraphicsLineItem>
qmake: QT += widgets
Since: Qt 4.2
继承: QGraphicsItem

公共函数

QGraphicsLineItem (QGraphicsItem * parent = Q_NULLPTR)
QGraphicsLineItem (const QLineF & line , QGraphicsItem * parent = Q_NULLPTR)
QGraphicsLineItem (qreal x1 , qreal y1 , qreal x2 , qreal y2 , QGraphicsItem * parent = Q_NULLPTR)
~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
virtual bool contains (const QPointF & point ) const
virtual bool isObscuredBy (const QGraphicsItem * item ) const
virtual QPainterPath opaqueArea () const
virtual void paint (QPainter * painter , const QStyleOptionGraphicsItem * option , QWidget * widget = Q_NULLPTR)
virtual QPainterPath shape () const
virtual int type () const

额外继承成员

详细描述

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 ,和 图形视图框架 .

成员函数文档编制

QGraphicsLineItem:: QGraphicsLineItem ( QGraphicsItem * parent = Q_NULLPTR)

构造 QGraphicsLineItem . parent 会被传递给 QGraphicsItem 的构造函数。

另请参阅 QGraphicsScene::addItem ().

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

构造 QGraphicsLineItem ,使用 line 作为默认线条。 parent 会被传递给 QGraphicsItem 的构造函数。

另请参阅 QGraphicsScene::addItem ().

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

构造 QGraphicsLineItem , using the line between ( x1 , y1 ) 和 ( x2 , y2 ) 作为默认线条。 parent 会被传递给 QGraphicsItem 的构造函数。

另请参阅 QGraphicsScene::addItem ().

QGraphicsLineItem:: ~QGraphicsLineItem ()

销毁 QGraphicsLineItem .

[virtual] QRectF QGraphicsLineItem:: boundingRect () const

重实现自 QGraphicsItem::boundingRect ().

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

重实现自 QGraphicsItem::contains ().

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

重实现自 QGraphicsItem::isObscuredBy ().

QLineF QGraphicsLineItem:: line () const

返回项的线条,或 null 线条若未设置线条。

另请参阅 setLine ().

[virtual] QPainterPath QGraphicsLineItem:: opaqueArea () const

重实现自 QGraphicsItem::opaqueArea ().

[virtual] void QGraphicsLineItem:: paint ( QPainter * painter , const QStyleOptionGraphicsItem * option , QWidget * widget = Q_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 ().

[virtual] QPainterPath QGraphicsLineItem:: shape () const

重实现自 QGraphicsItem::shape ().

[virtual] int QGraphicsLineItem:: type () const

重实现自 QGraphicsItem::type ().