zoukankan      html  css  js  c++  java
  • Qt 常用类 (4)—— QPoint

    转载:落叶知秋时

    QPoint 类代表一个坐标点,实现在 QtCore 共享库中。它可以认为是一个整型的横坐标和一个整型的纵坐标的组合。

    构造

    QPoint 类支持以下两种构造方式:

    QPoint();     // 构造横纵坐标均为 0 的 QPoint 对象  
    QPoint(int x, int y);    // 构造横纵坐标分别为 x 和 y 的 QPont 对象  

    属性

    通过以下成员函数可得到 QPoint 对象中的横纵坐标的引用

    int &rx();    // 得到横坐标的引用  
    int &ry();    // 到到纵坐标的引用  

    注意这些引用都不是只读的,也就是说可以通过它们直接修改 QPoint。

    通过以下的成员函数可以设置 QPoint 对象中的横纵坐标:

    void setX(int x);    // 设置横坐标为 x  
    void setY(int y);    // 设置纵坐标为 y  

    下面两个成员函数则是只读的,可以获得 QPoint 对象中的横纵坐标:

    int x() const;    // 获得横坐标  
    int y() const;    // 获得纵坐标 

    操作符

    QPoint 类支持加法和减法的复合赋值操作:

    QPoint &operator+=(const QPoint &point);    // 加赋值  
    QPoint &operator-=(const QPoint &point);    // 减赋值 

    这两个操作符是它的成员。而以下的操作符则不是它的成员:

    const QPoint operator+(const QPoint &p1, const QPoint &p2);    // 加法  
    const QPoint operator-(const QPoint &p1, const QPoint &p2);     // 减法  
    const QPoint operator-(const QPoint &point);                    // 取负数  
    bool operator==(const QPoint &p1, const QPoint &p2);            // 判断是否相等  
    bool operator!=(const QPoint &p1, const QPoint);                // 判断是否不等  
  • 相关阅读:
    WindowsServer2003SP2EnterpriseEdition激活码
    2016/12/14渗透学习总结
    技术之路注定孤独
    几道office题的总结
    一路走来,只是清风
    【IIS】IIS中同时满足集成模式和经典模式
    IntelliJ IDEA如何build path
    kafka的集群安装
    尚硅谷 kafka
    队列
  • 原文地址:https://www.cnblogs.com/fuqia/p/8909153.html
Copyright © 2011-2022 走看看