QLine#

The QLine class provides a two-dimensional vector using integer precision. More

Inheritance diagram of PySide6.QtCore.QLine

Synopsis#

Functions#

Note

This documentation may contain snippets that were automatically translated from C++ to Python. We always welcome contributions to the snippet translation. If you see an issue with the translation, you can also let us know by creating a ticket on https:/bugreports.qt.io/projects/PYSIDE

Detailed Description#

A QLine describes a finite length line (or a line segment) on a two-dimensional surface. The start and end points of the line are specified using integer point accuracy for coordinates. Use the QLineF constructor to retrieve a floating point copy.

qline-point1

qline-coordinates2

The positions of the line’s start and end points can be retrieved using the p1() , x1() , y1() , p2() , x2() , and y2() functions. The dx() and dy() functions return the horizontal and vertical components of the line. Use isNull() to determine whether the QLine represents a valid line or a null line.

Finally, the line can be translated a given offset using the translate() function.

See also

QLineF QPolygon QRect

class PySide6.QtCore.QLine#

PySide6.QtCore.QLine(pt1, pt2)

PySide6.QtCore.QLine(x1, y1, x2, y2)

Parameters:

Constructs a null line.

Constructs a line object that represents the line between p1 and p2.

Constructs a line object that represents the line between (x1, y1) and (x2, y2).

PySide6.QtCore.QLine.__reduce__()#
Return type:

object

PySide6.QtCore.QLine.__repr__()#
Return type:

object

PySide6.QtCore.QLine.center()#
Return type:

PySide6.QtCore.QPoint

Returns the center point of this line. This is equivalent to ( p1() + p2() ) / 2, except it will never overflow.

PySide6.QtCore.QLine.dx()#
Return type:

int

Returns the horizontal component of the line’s vector.

See also

dy()

PySide6.QtCore.QLine.dy()#
Return type:

int

Returns the vertical component of the line’s vector.

See also

dx()

PySide6.QtCore.QLine.isNull()#
Return type:

bool

Returns true if the line does not have distinct start and end points; otherwise returns false.

PySide6.QtCore.QLine.__ne__(d)#
Parameters:

dPySide6.QtCore.QLine

Return type:

bool

Returns true if the given line is not the same as this line.

A line is different from another line if any of their start or end points differ, or the internal order of the points is different.

PySide6.QtCore.QLine.__mul__(m)#
Parameters:

mPySide6.QtGui.QTransform

Return type:

PySide6.QtCore.QLine

PySide6.QtCore.QLine.__eq__(d)#
Parameters:

dPySide6.QtCore.QLine

Return type:

bool

Returns true if the given line is the same as this line.

A line is identical to another line if the start and end points are identical, and the internal order of the points is the same.

PySide6.QtCore.QLine.p1()#
Return type:

PySide6.QtCore.QPoint

Returns the line’s start point.

See also

setP1() x1() y1() p2()

PySide6.QtCore.QLine.p2()#
Return type:

PySide6.QtCore.QPoint

Returns the line’s end point.

See also

setP2() x2() y2() p1()

PySide6.QtCore.QLine.setLine(x1, y1, x2, y2)#
Parameters:
  • x1 – int

  • y1 – int

  • x2 – int

  • y2 – int

Sets this line to the start in x1, y1 and end in x2, y2.

PySide6.QtCore.QLine.setP1(p1)#
Parameters:

p1PySide6.QtCore.QPoint

Sets the starting point of this line to p1.

See also

setP2() p1()

PySide6.QtCore.QLine.setP2(p2)#
Parameters:

p2PySide6.QtCore.QPoint

Sets the end point of this line to p2.

See also

setP1() p2()

PySide6.QtCore.QLine.setPoints(p1, p2)#
Parameters:

Sets the start point of this line to p1 and the end point of this line to p2.

PySide6.QtCore.QLine.toLineF()#
Return type:

PySide6.QtCore.QLineF

Returns this line as a line with floating point accuracy.

See also

toLine()

PySide6.QtCore.QLine.toTuple()#
Return type:

object

PySide6.QtCore.QLine.translate(p)#
Parameters:

pPySide6.QtCore.QPoint

Translates this line by the given offset.

PySide6.QtCore.QLine.translate(dx, dy)
Parameters:
  • dx – int

  • dy – int

This is an overloaded function.

Translates this line the distance specified by dx and dy.

PySide6.QtCore.QLine.translated(p)#
Parameters:

pPySide6.QtCore.QPoint

Return type:

PySide6.QtCore.QLine

Returns this line translated by the given offset.

PySide6.QtCore.QLine.translated(dx, dy)
Parameters:
  • dx – int

  • dy – int

Return type:

PySide6.QtCore.QLine

This is an overloaded function.

Returns this line translated the distance specified by dx and dy.

PySide6.QtCore.QLine.x1()#
Return type:

int

Returns the x-coordinate of the line’s start point.

See also

p1()

PySide6.QtCore.QLine.x2()#
Return type:

int

Returns the x-coordinate of the line’s end point.

See also

p2()

PySide6.QtCore.QLine.y1()#
Return type:

int

Returns the y-coordinate of the line’s start point.

See also

p1()

PySide6.QtCore.QLine.y2()#
Return type:

int

Returns the y-coordinate of the line’s end point.

See also

p2()