QGraphicsLineItem¶
The
QGraphicsLineItem
class provides a line item that you can add to aQGraphicsScene
. More…

Synopsis¶
Detailed Description¶
To set the item’s line, pass a
QLineF
toQGraphicsLineItem
‘s constructor, or call thesetLine()
function. Theline()
function returns the current line. By default the line is black with a width of 0, but you can change this by callingsetPen()
.![]()
QGraphicsLineItem
uses the line and the pen width to provide a reasonable implementation ofboundingRect()
,shape()
, andcontains()
. Thepaint()
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
- param y1
qreal
- param line
QLineF
- param y2
qreal
- param x1
qreal
- param x2
qreal
Constructs a
QGraphicsLineItem
.parent
is passed toQGraphicsItem
‘s constructor.See also
Constructs a
QGraphicsLineItem
, usingline
as the default line.parent
is passed toQGraphicsItem
‘s constructor.See also
Constructs a
QGraphicsLineItem
, using the line between (x1
,y1
) and (x2
,y2
) as the default line.parent
is passed toQGraphicsItem
‘s constructor.See also
-
PySide2.QtWidgets.QGraphicsLineItem.
line
()¶ - Return type
QLineF
Returns the item’s line, or a null line if no line has been set.
See also
-
PySide2.QtWidgets.QGraphicsLineItem.
pen
()¶ - Return type
QPen
Returns the item’s pen, or a black solid 0-width pen if no pen has been set.
See also
-
PySide2.QtWidgets.QGraphicsLineItem.
setLine
(line)¶ - Parameters
line –
QLineF
Sets the item’s line to be the given
line
.See also
-
PySide2.QtWidgets.QGraphicsLineItem.
setLine
(x1, y1, x2, y2) - Parameters
x1 –
qreal
y1 –
qreal
x2 –
qreal
y2 –
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))
.