CopperSpice API  1.7.2
QLine Class Reference

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

Public Methods

 QLine () = default
 
 QLine (const QPoint &point1, const QPoint &point2)
 
 QLine (int x1, int y1, int x2, int y2)
 
int dx () const
 
int dy () const
 
bool isNull () const
 
bool operator!= (const QLine &line) const
 
bool operator== (const QLine &line) const
 
QPoint p1 () const
 
QPoint p2 () const
 
void setLine (int x1, int y1, int x2, int y2)
 
void setP1 (const QPoint &point)
 
void setP2 (const QPoint &point)
 
void setPoints (const QPoint &point1, const QPoint &point2)
 
void translate (const QPoint &offset)
 
void translate (int dx, int dy)
 
QLine translated (const QPoint &offset) const
 
QLine translated (int dx, int dy) const
 
int x1 () const
 
int x2 () const
 
int y1 () const
 
int y2 () const
 

Related Functions

These are not member functions

QDataStreamoperator<< (QDataStream &stream, const QLine &line)
 
QDataStreamoperator>> (QDataStream &stream, QLine &line)
 

Detailed Description

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

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.

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

Constructor & Destructor Documentation

QLine::QLine ( )
default

Constructs a null QLine.

QLine::QLine ( const QPoint point1,
const QPoint point2 
)
inline

Constructs a line object that represents the line between point1 and point2.

QLine::QLine ( int  x1,
int  y1,
int  x2,
int  y2 
)
inline

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

Method Documentation

int QLine::dx ( ) const
inline

Returns the horizontal component of the line's vector.

See also
dy()
int QLine::dy ( ) const
inline

Returns the vertical component of the line's vector.

See also
dx()
bool QLine::isNull ( ) const
inline

Returns true if the line is not set up with valid start and end point, otherwise returns false.

bool QLine::operator!= ( const QLine &  line) const
inline

Returns true if the given line is not the same as the current QLine. 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.

bool QLine::operator== ( const QLine &  line) const
inline

Returns true if the given line is the same as the current QLine. 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.

QPoint QLine::p1 ( ) const
inline

Returns the line's start point.

See also
setP1(), x1(), y1(), p2()
QPoint QLine::p2 ( ) const
inline

Returns the line's end point.

See also
setP2(), x2(), y2(), p1()
void QLine::setLine ( int  x1,
int  y1,
int  x2,
int  y2 
)
inline

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

See also
setP1(), setP2(), p1(), p2()
void QLine::setP1 ( const QPoint point)
inline

Sets the starting point of this line to point.

See also
setP2(), p1()
void QLine::setP2 ( const QPoint point)
inline

Sets the end point of this line to point.

See also
setP1(), p2()
void QLine::setPoints ( const QPoint point1,
const QPoint point2 
)
inline

Sets the start point of this line to point1 and the end point of this line to point2.

See also
setP1(), setP2(), p1(), p2()
void QLine::translate ( const QPoint offset)
inline

Translates this line by the given offset.

void QLine::translate ( int  dx,
int  dy 
)
inline

Translates this line the distance specified by dx and dy.

QLine QLine::translated ( const QPoint offset) const
inline

Returns this line translated by the given offset.

QLine QLine::translated ( int  dx,
int  dy 
) const
inline

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

int QLine::x1 ( ) const
inline

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

See also
p1()
int QLine::x2 ( ) const
inline

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

See also
p2()
int QLine::y1 ( ) const
inline

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

See also
p1()
int QLine::y2 ( ) const
inline

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

See also
p2()

Friends And Related Function Documentation

QDataStream & operator<< ( QDataStream stream,
const QLine &  line 
)
related

Writes the given line to the given stream and returns a reference to the stream.

Refer to Serializing Data Types for additional information.

QDataStream & operator>> ( QDataStream stream,
QLine &  line 
)
related

Reads a line from the given stream into the given line and returns a reference to the stream.

Refer to Serializing Data Types for additional information.