Qt common classes (4) - QPoint

Reprinted: Fallen leaves know autumn

The QPoint class represents a coordinate point and is implemented in the QtCore shared library. It can be thought of as a combination of an integer abscissa and an integer ordinate.

structure

The QPoint class supports the following two construction methods:

QPoint();      // Construct a QPoint object with horizontal and vertical coordinates of 0   
QPoint( int x, int y);     // Construct a QPoint object with horizontal and vertical coordinates of x and y respectively  

Attributes

The reference to the horizontal and vertical coordinates in the QPoint object can be obtained through the following member functions

int &rx();     // get a reference to the abscissa   
int &ry();     // get a reference to the ordinate  

Note that none of these references are read-only, which means that QPoint can be modified directly through them.

 

The horizontal and vertical coordinates in the QPoint object can be set through the following member functions:

void setX( int x);     // Set the abscissa to x   
void setY( int y);     // Set the ordinate to y  

 

The following two member functions are read-only and can obtain the horizontal and vertical coordinates in the QPoint object:

int x() const ;     // get the abscissa   
int y() const ;     // get the ordinate

 

operator

The QPoint class supports compound assignment operations for addition and subtraction:

QPoint & operator +=( const QPoint &point);     // Add assignment   
QPoint & operator -=( const QPoint &point);     // Subtract assignment

These two operators are its members. The following operators are not members of it:

const QPoint operator +( const QPoint &p1, const QPoint & p2);     // Addition   
const QPoint operator -( const QPoint &p1, const QPoint &p2);      // Subtraction   
const QPoint operator -( const QPoint &point);                     // Negative   
bool  operator ==( const QPoint &p1, const QPoint &p2);             // Determine equality   
bool  operator !=( constQPoint &p1, const QPoint);                 // Determine whether it is not equal  

 

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=324645082&siteId=291194637