内容表

上一话题

QGraphicsLayoutItem

下一话题

QGraphicsLinearLayout

QGraphicsLineItem

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

Inheritance diagram of PySide2.QtWidgets.QGraphicsLineItem

概要

函数

详细描述

To set the item’s line, pass a QLineF to QGraphicsLineItem ‘s constructor, or call the setLine() function. The line() function returns the current line. By default the line is black with a width of 0, but you can change this by calling setPen() .

../../_images/graphicsview-lineitem.png

QGraphicsLineItem uses the line and the pen width to provide a reasonable implementation of boundingRect() , shape() ,和 contains() paint() function draws the line using the item’s associated pen.

class QGraphicsLineItem ( [ parent=None ] )

QGraphicsLineItem(line[, parent=None])

QGraphicsLineItem(x1, y1, x2, y2[, parent=None])

param parent

QGraphicsItem

param y1

qreal

param line

QLineF

param y2

qreal

param x1

qreal

param x2

qreal

构造 QGraphicsLineItem . parent 会被传递给 QGraphicsItem ‘s constructor.

另请参阅

addItem()

构造 QGraphicsLineItem ,使用 line 作为默认线条。 parent 会被传递给 QGraphicsItem ‘s constructor.

另请参阅

addItem()

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

另请参阅

addItem()

PySide2.QtWidgets.QGraphicsLineItem. line ( )
返回类型

QLineF

Returns the item’s line, or a null line if no line has been set.

另请参阅

setLine()

PySide2.QtWidgets.QGraphicsLineItem. pen ( )
返回类型

QPen

Returns the item’s pen, or a black solid 0-width pen if no pen has been set.

另请参阅

setPen()

PySide2.QtWidgets.QGraphicsLineItem. setLine ( line )
参数

line QLineF

Sets the item’s line to be the given line .

另请参阅

line()

PySide2.QtWidgets.QGraphicsLineItem. setLine ( x1 , y1 , x2 , y2 )
参数
  • x1 qreal

  • y1 qreal

  • x2 qreal

  • y2 qreal

这是重载函数。

Sets the item’s line to be the line between ( x1 , y1 ) 和 ( x2 , y2 ).

这如同调用 setLine(QLineF(x1, y1, x2, y2)) .

PySide2.QtWidgets.QGraphicsLineItem. setPen ( pen )
参数

pen QPen

Sets the item’s pen to pen 。若未设置钢笔,将使用黑色 0 宽度实心钢笔绘制线条。

另请参阅

pen()