QGraphicsLineItem露

The QGraphicsLineItem class provides a line item that you can add to a QGraphicsScene . More鈥�

Inheritance diagram of PySide2.QtWidgets.QGraphicsLineItem

Synopsis露

Functions露

Detailed Description露

To set the item鈥檚 line, pass a QLineF to QGraphicsLineItem 鈥榮 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() , and contains() . The paint() function draws the line using the item鈥檚 associated pen.

class PySide2.QtWidgets.QGraphicsLineItem([parent=None])露

PySide2.QtWidgets.QGraphicsLineItem(line[, parent=None])

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

param parent:

PySide2.QtWidgets.QGraphicsItem

param y1:

float

param line:

PySide2.QtCore.QLineF

param y2:

float

param x1:

float

param x2:

float

Constructs a QGraphicsLineItem . parent is passed to QGraphicsItem 鈥榮 constructor.

See also

addItem()

Constructs a QGraphicsLineItem , using line as the default line. parent is passed to QGraphicsItem 鈥榮 constructor.

See also

addItem()

Constructs a QGraphicsLineItem , using the line between (x1 , y1 ) and (x2 , y2 ) as the default line. parent is passed to QGraphicsItem 鈥榮 constructor.

See also

addItem()

PySide2.QtWidgets.QGraphicsLineItem.line()露
Return type:

PySide2.QtCore.QLineF

Returns the item鈥檚 line, or a null line if no line has been set.

See also

setLine()

PySide2.QtWidgets.QGraphicsLineItem.pen()露
Return type:

PySide2.QtGui.QPen

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

See also

setPen()

PySide2.QtWidgets.QGraphicsLineItem.setLine(line)露
Parameters:

line 鈥� PySide2.QtCore.QLineF

Sets the item鈥檚 line to be the given line .

See also

line()

PySide2.QtWidgets.QGraphicsLineItem.setLine(x1, y1, x2, y2)
Parameters:
  • x1 鈥� float

  • y1 鈥� float

  • x2 鈥� float

  • y2 鈥� float

This is an overloaded function.

Sets the item鈥檚 line to be the line between (x1 , y1 ) and (x2 , y2 ).

This is the same as calling setLine(QLineF(x1, y1, x2, y2)) .

PySide2.QtWidgets.QGraphicsLineItem.setPen(pen)露
Parameters:

pen 鈥� PySide2.QtGui.QPen

Sets the item鈥檚 pen to pen . If no pen is set, the line will be painted using a black solid 0-width pen.

See also

pen()