本系列文章长期更新修改.
QPoint,是Qt的一个常用数据结构,它是x,y整数坐标的封装,本质上就是两个int的结构体.
属性:
Methods
- __init__ (self)
- __init__ (self, int xpos, int ypos)
- __init__ (self, QPoint other)
- bool isNull (self)
- int manhattanLength (self)
- setX (self, int xpos)
- setY (self, int ypos)
- int x (self)
- int y (self)
Special Methods
- QPoint __mul__ (self, QMatrix m)
- QPoint __mul__ (self, QTransform m)
- QPoint __add__ (self, QPoint p2)
- QPoint __div__ (self, float c)
- bool __eq__ (self, QPoint p2)
- QPoint __iadd__ (self, QPoint p)
- QPoint __idiv__ (self, float c)
- QPoint __imul__ (self, float c)
- QPoint __isub__ (self, QPoint p)
- QPoint __mul__ (self, float c)
- bool __ne__ (self, QPoint p2)
- QPoint __neg__ (self, QPoint p)
- int __nonzero__ (self)
- object __repr__ (self)
- QPoint __sub__ (self, QPoint p2)
详细分析:
1.主要属性
QPoint的主要属性就是x坐标和y坐标,在初始化如果不提供参数,x,y则为0.可以通过下面相关函数设置x,y坐标:
- __init__ (self)
- __init__ (self, int xpos, int ypos)
- __init__ (self, QPoint other)
- setX (self, int xpos)
- setY (self, int ypos)
- int x (self)
- int y (self)
2.isNull
如果x,y都为0,那么isNull()返回true
- bool isNull (self)
3.曼哈顿距离
manhattanLength()能返回(0,0)到(x,y)的曼哈顿距离,数值上等于|x|+|y|.
- int manhattanLength (self)