QGraphicsLineItem

Inheritance diagram of PySide2.QtWidgets.QGraphicsLineItem

Synopsis

Functions

Detailed Description

The PySide2.QtWidgets.QGraphicsLineItem class provides a line item that you can add to a PySide2.QtWidgets.QGraphicsScene .

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

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

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

class PySide2.QtWidgets.QGraphicsLineItem([parent=nullptr])
class PySide2.QtWidgets.QGraphicsLineItem(line[, parent=nullptr])
class PySide2.QtWidgets.QGraphicsLineItem(x1, y1, x2, y2[, parent=nullptr])
Parameters:

Constructs a PySide2.QtWidgets.QGraphicsLineItem . parent is passed to PySide2.QtWidgets.QGraphicsItem ‘s constructor.

Constructs a PySide2.QtWidgets.QGraphicsLineItem , using line as the default line. parent is passed to PySide2.QtWidgets.QGraphicsItem ‘s constructor.

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

PySide2.QtWidgets.QGraphicsLineItem.line()
Return type:PySide2.QtCore.QLineF

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

PySide2.QtWidgets.QGraphicsLineItem.pen()
Return type:PySide2.QtGui.QPen

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

PySide2.QtWidgets.QGraphicsLineItem.setLine(x1, y1, x2, y2)
Parameters:
  • x1PySide2.QtCore.qreal
  • y1PySide2.QtCore.qreal
  • x2PySide2.QtCore.qreal
  • y2PySide2.QtCore.qreal

This is an overloaded function.

Sets the item’s 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.setLine(line)
Parameters:linePySide2.QtCore.QLineF

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

PySide2.QtWidgets.QGraphicsLineItem.setPen(pen)
Parameters:penPySide2.QtGui.QPen

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