一、QPoint 类:
    封装了我们常用用到的坐标点 (x, y), 常用的 API :

    1. //构造函数
    2. // 构造一个坐标原点, 即(0, 0)
    3. QPoint::QPoint();
    4. // 参数为 x轴坐标, y轴坐标
    5. QPoint::QPoint(int xpos, int ypos);
    6. // 设置x轴坐标
    7. void QPoint::setX(int x);
    8. // 设置y轴坐标
    9. void QPoint::setY(int y);
    10. // 得到x轴坐标
    11. int QPoint::x() const;
    12. // 得到x轴坐标的引用
    13. int &QPoint::rx();
    14. // 得到y轴坐标
    15. int QPoint::y() const;
    16. // 得到y轴坐标的引用
    17. int &QPoint::ry();
    18. // 直接通过坐标对象进行算术运算: 加减乘除
    19. QPoint &QPoint::operator*=(float factor);
    20. QPoint &QPoint::operator*=(double factor);
    21. QPoint &QPoint::operator*=(int factor);
    22. QPoint &QPoint::operator+=(const QPoint &point);
    23. QPoint &QPoint::operator-=(const QPoint &point);
    24. QPoint &QPoint::operator/=(qreal divisor);

    二、QLine类:
    QLine 是一个直线类,封装了两个坐标点 (两点确定一条直线)

    1. // 构造函数
    2. // 构造一个空对象
    3. QLine::QLine();
    4. // 构造一条直线, 通过两个坐标点
    5. QLine::QLine(const QPoint &p1, const QPoint &p2);
    6. // 从点 (x1, y1) 到 (x2, y2)
    7. QLine::QLine(int x1, int y1, int x2, int y2);
    8. // 给直线对象设置坐标点
    9. void QLine::setPoints(const QPoint &p1, const QPoint &p2);
    10. // 起始点(x1, y1), 终点(x2, y2)
    11. void QLine::setLine(int x1, int y1, int x2, int y2);
    12. // 设置直线的起点坐标
    13. void QLine::setP1(const QPoint &p1);
    14. // 设置直线的终点坐标
    15. void QLine::setP2(const QPoint &p2);
    16. // 返回直线的起始点坐标
    17. QPoint QLine::p1() const;
    18. // 返回直线的终点坐标
    19. QPoint QLine::p2() const;
    20. // 返回值直线的中心点坐标, (p1() + p2()) / 2
    21. QPoint QLine::center() const;
    22. // 返回值直线起点的 x 坐标
    23. int QLine::x1() const;
    24. // 返回值直线终点的 x 坐标
    25. int QLine::x2() const;
    26. // 返回值直线起点的 y 坐标
    27. int QLine::y1() const;
    28. // 返回值直线终点的 y 坐标
    29. int QLine::y2() const;
    30. // 用给定的坐标点平移这条直线
    31. void QLine::translate(const QPoint &offset);
    32. void QLine::translate(int dx, int dy);
    33. // 用给定的坐标点平移这条直线, 返回平移之后的坐标点
    34. QLine QLine::translated(const QPoint &offset) const;
    35. QLine QLine::translated(int dx, int dy) const;
    36. // 直线对象进行比较
    37. bool QLine::operator!=(const QLine &line) const;
    38. bool QLine::operator==(const QLine &line) const;

    三、QSize类:
    QSize 类用来形容长度和宽度,常用的 API:

    1. // 构造函数
    2. // 构造空对象, 对象中的宽和高都是无效的
    3. QSize::QSize();
    4. // 使用宽和高构造一个有效对象
    5. QSize::QSize(int width, int height);
    6. // 设置宽度
    7. void QSize::setWidth(int width)
    8. // 设置高度
    9. void QSize::setHeight(int height);
    10. // 得到宽度
    11. int QSize::width() const;
    12. // 得到宽度的引用
    13. int &QSize::rwidth();
    14. // 得到高度
    15. int QSize::height() const;
    16. // 得到高度的引用
    17. int &QSize::rheight();
    18. // 交换高度和宽度的值
    19. void QSize::transpose();
    20. // 交换高度和宽度的值, 返回交换之后的尺寸信息
    21. QSize QSize::transposed() const;
    22. // 进行算法运算: 加减乘除
    23. QSize &QSize::operator*=(qreal factor);
    24. QSize &QSize::operator+=(const QSize &size);
    25. QSize &QSize::operator-=(const QSize &size);
    26. QSize &QSize::operator/=(qreal divisor);

    四、QRVect:

    1. // 构造函数
    2. // 构造一个空对象
    3. QRect::QRect();
    4. // 基于左上角坐标, 和右下角坐标构造一个矩形对象
    5. QRect::QRect(const QPoint &topLeft, const QPoint &bottomRight);
    6. // 基于左上角坐标, 和 宽度, 高度构造一个矩形对象
    7. QRect::QRect(const QPoint &topLeft, const QSize &size);
    8. // 通过 左上角坐标(x, y), 和 矩形尺寸(width, height) 构造一个矩形对象
    9. QRect::QRect(int x, int y, int width, int height);
    10. // 设置矩形的尺寸信息, 左上角坐标不变
    11. void QRect::setSize(const QSize &size);
    12. // 设置矩形左上角坐标为(x,y), 大小为(width, height)
    13. void QRect::setRect(int x, int y, int width, int height);
    14. // 设置矩形宽度
    15. void QRect::setWidth(int width);
    16. // 设置矩形高度
    17. void QRect::setHeight(int height);
    18. // 返回值矩形左上角坐标
    19. QPoint QRect::topLeft() const;
    20. // 返回矩形右上角坐标
    21. // 该坐标点值为: QPoint(left() + width() -1, top())
    22. QPoint QRect::topRight() const;
    23. // 返回矩形左下角坐标
    24. // 该坐标点值为: QPoint(left(), top() + height() - 1)
    25. QPoint QRect::bottomLeft() const;
    26. // 返回矩形右下角坐标
    27. // 该坐标点值为: QPoint(left() + width() -1, top() + height() - 1)
    28. QPoint QRect::bottomRight() const;
    29. // 返回矩形中心点坐标
    30. QPoint QRect::center() const;
    31. // 返回矩形上边缘y轴坐标
    32. int QRect::top() const;
    33. int QRect::y() const;
    34. // 返回值矩形下边缘y轴坐标
    35. int QRect::bottom() const;
    36. // 返回矩形左边缘 x轴坐标
    37. int QRect::x() const;
    38. int QRect::left() const;
    39. // 返回矩形右边缘x轴坐标
    40. int QRect::right() const;
    41. // 返回矩形的高度
    42. int QRect::width() const;
    43. // 返回矩形的宽度
    44. int QRect::height() const;
    45. // 返回矩形的尺寸信息
    46. QSize QRect::size() const;