QRect Class Reference
[QtCore module]
查阅QRect类定义使用整数精度在平面的矩形。More…
Methods
- __init__ (self)
- __init__ (self, int aleft, int atop, int awidth, int aheight)
- __init__ (self, QPoint atopLeft, QPoint abottomRight)
- __init__ (self, QPoint atopLeft, QSize asize)
- __init__ (self, QRect)
- adjust (self, int dx1, int dy1, int dx2, int dy2)
- QRect adjusted (self, int xp1, int yp1, int xp2, int yp2)
- int bottom (self)
- QPoint bottomLeft (self)
- QPoint bottomRight (self)
- QPoint center (self)
- bool contains (self, QPoint point, bool proper = False)
- bool contains (self, QRect rectangle, bool proper = False)
- bool contains (self, int ax, int ay, bool aproper)
- bool contains (self, int ax, int ay)
- (int xp1, int yp1, int xp2, int yp2) getCoords (self)
- (int ax, int ay, int aw, int ah) getRect (self)
- int height (self)
- QRect intersect (self, QRect r)
- QRect intersected (self, QRect other)
- bool intersects (self, QRect r)
- bool isEmpty (self)
- bool isNull (self)
- bool isValid (self)
- int left (self)
- moveBottom (self, int pos)
- moveBottomLeft (self, QPoint p)
- moveBottomRight (self, QPoint p)
- moveCenter (self, QPoint p)
- moveLeft (self, int pos)
- moveRight (self, int pos)
- moveTo (self, int ax, int ay)
- moveTo (self, QPoint p)
- moveTop (self, int pos)
- moveTopLeft (self, QPoint p)
- moveTopRight (self, QPoint p)
- QRect normalized (self)
- int right (self)
- setBottom (self, int pos)
- setBottomLeft (self, QPoint p)
- setBottomRight (self, QPoint p)
- setCoords (self, int xp1, int yp1, int xp2, int yp2)
- setHeight (self, int h)
- setLeft (self, int pos)
- setRect (self, int ax, int ay, int aw, int ah)
- setRight (self, int pos)
- setSize (self, QSize s)
- setTop (self, int pos)
- setTopLeft (self, QPoint p)
- setTopRight (self, QPoint p)
- setWidth (self, int w)
- setX (self, int ax)
- setY (self, int ay)
- QSize size (self)
- int top (self)
- QPoint topLeft (self)
- QPoint topRight (self)
- translate (self, int dx, int dy)
- translate (self, QPoint p)
- QRect translated (self, int dx, int dy)
- QRect translated (self, QPoint p)
- QRect unite (self, QRect r)
- QRect united (self, QRect r)
- int width (self)
- int x (self)
- int y (self)
Special Methods
- QRect __and__ (self, QRect r)
- int __bool__ (self)
- int __contains__ (self, QPoint p)
- int __contains__ (self, QRect r)
- bool __eq__ (self, QRect r2)
- QRect __iand__ (self, QRect r)
- QRect __ior__ (self, QRect r)
- bool __ne__ (self, QRect r2)
- QRect __or__ (self, QRect r)
- str __repr__ (self)
Detailed Description
这个类可以醃制。
查阅QRect类定义使用整数精度在平面的矩形。
一个矩形,通常表示为左上角和尺寸。一个查阅QRect的大小(宽度和高度)总是等于其形成的基础,其呈现的数学矩形。
阿查阅QRect可以用一组左,上,宽度和高度的整数,或者从一个被构造QPoint和QSize。下面的代码创建两个相同的矩形。
QRect r1(100, 200, 11, 16);
QRect r2([QPoint]($docs-qpoint.html)(100, 200), [QSize]($docs-qsize.html)(11, 16));
还有就是使用左上角和右下角坐标创建一个查阅QRect第三个构造函数,但是我们建议您避免使用它。理由是,由于历史原因,返回的值bottom()和right()函数偏离矩形的真实右下角。
查阅QRect类提供了返回的各种矩形坐标函数的集合,使操纵这些。查阅QRect也提供功能,以矩形相对移动到不同的坐标。此外,还有一个moveTo( )函数,移动矩形,留下它的左上角在给定的坐标。或者,所述translate()函数使矩形给定的偏移量相对于当前位置,并且translated( )函数返回这个矩形的翻译件。
该size( )函数返回rectange的尺寸为QSize。的尺寸也可以单独使用检索到的width()和height()函数。操控方面使用setSize( )setWidth()或setHeight()函数。可替换地,大小可以通过应用或功能设定矩形的坐标,例如被改变,setBottom()或setRight( ) 。
该contains( )函数告诉一个给定的点是否是里面的矩形或没有了,intersects如果这个矩形相交与给定的矩形( )函数返回True。查阅QRect类还提供了intersected()函数返回相交的矩形,并在united( )函数将返回一个封装给定的矩形,这个矩形:
|  |
 |  |
| intersected() | united() |
 |
| intersected() | united() |
该isEmpty( )函数返回True,如果left( ) \u003eright()或top( ) \u003ebottom( ) 。需要注意的是一个空矩形是无效的:在isValid( )函数返回True,如果left( )\u003c=right( )and top( )\u003c=bottom( ) 。一个空矩形(isNull()== TRUE) ,另一方面,也将宽度和高度设置为0。
注意,由于该方式查阅QRect和QRectF被定义,一个空的查阅QRect在本质上以同样的方式定义为QRectF。
最后,相比查阅QRect对象可以被串流播放,以及。
Rendering
当使用一个anti-aliased画家,查阅QRect的边界线将对称地在数学矩形的边界线的两侧呈现。但使用一个别名画家(默认值)时,其他规则。
然后,用一个像素宽的画笔渲染时查阅QRect的边界线将呈现给正确的和数学矩形的边界线下方。
当与两个像素宽画笔绘制边界线会由数学矩形被分割在中间。这将是这种情况时的笔被设置成偶数个像素,而与像素数为奇数的笔绘制,备用像素将呈现向右和数学矩形中的一个像素的情况下。
|  |
 |  |
| Logical representation | One pixel wide pen |
|
 |
| Logical representation | One pixel wide pen |
|  |
 |  |
| Two pixel wide pen | Three pixel wide pen |
 |
| Two pixel wide pen | Three pixel wide pen |
Coordinates
查阅QRect类提供了返回的各种矩形坐标函数的集合,使操纵这些。查阅QRect也提供功能,以矩形相对移动到不同的坐标。
例如在left( )setLeft()和moveLeft()函数,例如:left()返回矩形的左边缘的x坐标,setLeft()设置矩形的左边缘到给定的x坐标(它可能会改变宽度,但决不会改变矩形的右边缘)和moveLeft( )移动整个矩形水平,使矩形的左边缘在给定的x坐标和尺寸不变。

请注意,返回的值的历史原因bottom()和right()函数偏离矩形的真实右下角:该right( )函数返回left() + width() - 1和bottom( )函数返回top() + height() - 1。同样是由返回的点的情况bottomRight( )的便利功能。另外, x和y的坐标topRight()和bottomLeft()函数,分别包含来自真右边缘和下边缘的偏差相同。
我们建议您使用x()+width()和y()+height( )找到真正的右下角,并避免right()和bottom( ) 。另一个解决方案是使用QRectF:该QRectF类定义使用浮点精度的坐标平面中的矩形,而QRectF.right()和QRectF.bottom( )函数do返回右边和底部坐标。
另外,也可以使用偏移量添加到该矩形的坐标adjust()函数,以及检索使用基于原来的1调整一个新的矩形的adjusted()函数。如果其中的宽度和高度为负时,用normalized()函数来检索其中的角部被交换的矩形。
此外,查阅QRect提供getCoords()函数,其提取的矩形的左上角和右下角的位置,并且getRect( )函数,它提取矩形的左上角,宽度和高度。使用setCoords()和setRect( )函数来处理矩形的坐标和尺寸一气呵成。
Method Documentation
QRect.__init__ (self)
构造一个空矩形。
See also isNull( ) 。
QRect.__init__ (self, int aleft, int atop, int awidth, int aheight)
构造一个矩形与给定topLeft和bottomRight角落。
See also setTopLeft()和setBottomRight( ) 。
QRect.__init__ (self, QPoint atopLeft, QPoint abottomRight)
构造一个矩形与给定topLeft角部和所述定size。
See also setTopLeft()和setSize( ) 。
QRect.__init__ (self, QPoint atopLeft, QSize asize)
构造一个矩形(x,y)作为它的左上角和给定的width和height。
See also setRect( ) 。
QRect.__init__ (self, QRect)
QRect.adjust (self, int dx1, int dy1, int dx2, int dy2)
添加dx1,dy1,dx2和dy2分别以矩形的现有的坐标。
See also adjusted()和setRect( ) 。
QRect QRect.adjusted (self, int xp1, int yp1, int xp2, int yp2)
[
返回一个新的矩形dx1,dy1,dx2和dy2分别加入到这个矩形的现有坐标。
]($docs-qrect.html)
int QRect.bottom (self)
返回矩形的底边的y坐标。
请注意,由于历史原因,该函数返回top()+height( ) - 1 ;使用y()+height()来获取真正的y坐标。
See also setBottom( )bottomLeft()和bottomRight( ) 。
QPoint QRect.bottomLeft (self)
返回矩形的左下角的位置。请注意,由于历史原因,该函数返回QPoint(left( )top()+height( ) - 1 ) 。
See also setBottomLeft( )bottom()和left( ) 。
QPoint QRect.bottomRight (self)
[
返回矩形的右下角的位置。
]($docs-qpoint.html)
请注意,由于历史原因,该函数返回QPoint(left()+width()-1 ,top()+height( ) - 1 ) 。
See also setBottomRight( )bottom()和right( ) 。
QPoint QRect.center (self)
[
返回矩形的中心点。
]($docs-qpoint.html)
See also moveCenter( ) 。
bool QRect.contains (self, QPoint point, bool proper = False)
返回True如果给定的point是内部或矩形的边缘,否则返回False 。如果proper诚然,这个功能只有在给定返回Truepoint is inside的矩形(即,不上的边缘)。
See also intersects( ) 。
bool QRect.contains (self, QRect rectangle, bool proper = False)
这是一个重载函数。
返回True如果点(x,y)是内部或矩形的边缘,否则返回False 。如果proper诚然,这个功能只有在点是完全的矩形(而不是在边缘)内返回True 。
bool QRect.contains (self, int ax, int ay, bool aproper)
这是一个重载函数。
返回True如果点(x,y)是这个矩形内,否则返回False 。
bool QRect.contains (self, int ax, int ay)
这是一个重载函数。
返回True如果给定的rectangle这是矩形内。否则返回False 。如果proper诚然,这个函数只返回True,如果rectangle完全是这个矩形(而不是在边缘)内。
(int xp1, int yp1, int xp2, int yp2) QRect.getCoords (self)
提取矩形的左上角的位置x1和y1和右下角为的位置x2和y2。
See also setCoords()和getRect( ) 。
(int ax, int ay, int aw, int ah) QRect.getRect (self)
提取矩形的左上角的位置x和y,其尺寸width和height。
See also setRect()和getCoords( ) 。
int QRect.height (self)
返回该矩形的高度。
See also setHeight( )width()和size( ) 。
QRect QRect.intersect (self, QRect r)
QRect QRect.intersected (self, QRect other)
[
返回此矩形的交集和给定的rectangle。需要注意的是r.intersected(s)相当于r & s。

这个函数中引入了Qt 4.2中。
]($docs-qrect.html)
See also intersects( )united()和operator&=( ) 。
bool QRect.intersects (self, QRect r)
如果这个矩形相交与给定的,则返回Truerectangle(即,至少有一个像素是两个矩形内),否则返回假。
相交的矩形可使用检索到的intersected()函数。
See also contains( ) 。
bool QRect.isEmpty (self)
返回True如果矩形为空,否则返回False 。
一个空矩形有一个left( ) \u003eright()或top( ) \u003ebottom( ) 。一个空矩形是无效的(即,参考isEmpty ( ) == !isValid())。
使用normalized()函数来检索其中的角部被交换的矩形。
See also isNull( )isValid()和normalized( ) 。
bool QRect.isNull (self)
返回True如果矩形为空矩形,否则返回False 。
空矩形具有的宽度和高度设置为0 (即right()==left( ) - 1bottom()==top( ) - 1 ) 。一个空的矩形也是空的,因此是无效的。
See also isEmpty()和isValid( ) 。
bool QRect.isValid (self)
返回True如果矩形是有效的,否则返回False 。
一个有效的矩形有一个left()\u003cright()和top()\u003cbottom( ) 。请注意,就像十字路口不平凡的操作没有定义无效矩形。一个有效的矩形不为空(即参考isValid ( ) == !isEmpty())。
See also isNull( )isEmpty()和normalized( ) 。
int QRect.left (self)
返回矩形的左边缘的x坐标。相当于x( ) 。
See also setLeft( )topLeft()和bottomLeft( ) 。
QRect.moveBottom (self, int pos)
移动矩形垂直,使矩形的底边在给定的y协调。矩形的尺寸是不变的。
See also bottom( )setBottom()和moveTop( ) 。
QRect.moveBottomLeft (self, QPoint p)
移动矩形,留下左下角在给定的position。矩形的尺寸是不变的。
See also setBottomLeft( )moveBottom()和moveLeft( ) 。
QRect.moveBottomRight (self, QPoint p)
移动矩形,留下右下角的定position。矩形的尺寸是不变的。
See also setBottomRight( )moveRight()和moveBottom( ) 。
QRect.moveCenter (self, QPoint p)
移动矩形,而使中心点在给定的position。矩形的尺寸是不变的。
See also center( ) 。
QRect.moveLeft (self, int pos)
水平移动矩形,使矩形的左边缘在给定的x协调。矩形的尺寸是不变的。
See also left( )setLeft()和moveRight( ) 。
QRect.moveRight (self, int pos)
水平移动矩形,使矩形的右边缘在给定的x协调。矩形的尺寸是不变的。
See also right( )setRight()和moveLeft( ) 。
QRect.moveTo (self, int ax, int ay)
移动矩形,留下左上角的指定位置(x,y) 。矩形的尺寸是不变的。
See also translate()和moveTopLeft( ) 。
QRect.moveTo (self, QPoint p)
移动矩形,留下左上角在给定的position。
QRect.moveTop (self, int pos)
移动矩形垂直,使矩形的顶边在给定的y协调。矩形的尺寸是不变的。
See also top( )setTop()和moveBottom( ) 。
QRect.moveTopLeft (self, QPoint p)
移动矩形,留下左上角在给定的position。矩形的尺寸是不变的。
See also setTopLeft( )moveTop()和moveLeft( ) 。
QRect.moveTopRight (self, QPoint p)
移动矩形,留下右上角的定position。矩形的尺寸是不变的。
See also setTopRight( )moveTop()和moveRight( ) 。
QRect QRect.normalized (self)
[
返回一个归一化的矩形,即,具有一个非负的宽度和高度的矩形。
]($docs-qrect.html)
If width()\u003c 0的函数交换的左右角部,并且交换的顶部和底部边角,如果height()\u003c 0 。
See also isValid()和isEmpty( ) 。
int QRect.right (self)
返回矩形的右边缘的x坐标。
请注意,由于历史原因,该函数返回left()+width( ) - 1 ;使用x()+width()来获取真正的x坐标。
See also setRight( )topRight()和bottomRight( ) 。
QRect.setBottom (self, int pos)
设置的矩形的底部边缘与给定的y协调。可能会改变高度,但决不会改变矩形的上边缘。
See also bottom()和moveBottom( ) 。
QRect.setBottomLeft (self, QPoint p)
设置矩形的左下角给定的position。可以改变大小,但决不会改变矩形的右上角。
See also bottomLeft()和moveBottomLeft( ) 。
QRect.setBottomRight (self, QPoint p)
设置矩形的右下角为给定的position。可以改变大小,但决不会改变矩形的左上角。
See also bottomRight()和moveBottomRight( ) 。
QRect.setCoords (self, int xp1, int yp1, int xp2, int yp2)
设置矩形的左上角的坐标为(x1,y1)和其右下角的坐标(x2,y2) 。
See also coords( )getCoords()和setRect( ) 。
QRect.setHeight (self, int h)
设置了矩形的高度为给定的height。底部边缘被改变,但不顶一个。
See also height()和setSize( ) 。
QRect.setLeft (self, int pos)
设置了矩形的左边缘到给定的x协调。可能会改变宽度,但决不会改变矩形的右边缘。
相当于setX( ) 。
QRect.setRect (self, int ax, int ay, int aw, int ah)
设置矩形的左上角的坐标为(x,y) ,并且其大小为给定的width和height。
See also rect( )getRect()和setCoords( ) 。
QRect.setRight (self, int pos)
设置了矩形的右边缘到给定的x协调。可能会改变宽度,但决不会改变矩形的左边缘。
See also right()和moveRight( ) 。
QRect.setSize (self, QSize s)
设置了矩形的大小给定的size。在左上角不移动。
See also size( )setWidth()和setHeight( ) 。
QRect.setTop (self, int pos)
设置了矩形的顶边到给定的y协调。可能会改变高度,但决不会改变矩形的底边。
相当于setY( ) 。
QRect.setTopLeft (self, QPoint p)
设置的矩形的左上角的给定position。可以改变大小,但决不会改变矩形的右下角。
See also topLeft()和moveTopLeft( ) 。
QRect.setTopRight (self, QPoint p)
设置矩形的右上角,以给定的position。可以改变大小,但决不会改变矩形的左下角。
See also topRight()和moveTopRight( ) 。
QRect.setWidth (self, int w)
设置了矩形的宽度与给定width。右边缘被改变,但不是左1 。
QRect.setX (self, int ax)
设置了矩形的左边缘到给定的x协调。可能会改变宽度,但决不会改变矩形的右边缘。
相当于setLeft( ) 。
See also x( )setY()和setTopLeft( ) 。
QRect.setY (self, int ay)
设置了矩形的顶边到给定的y协调。可能会改变高度,但决不会改变矩形的底边。
相当于setTop( ) 。
See also y( )setX()和setTopLeft( ) 。
QSize QRect.size (self)
[
返回矩形的大小。
]($docs-qsize.html)
See also setSize( )width()和height( ) 。
int QRect.top (self)
返回矩形的上边缘的y坐标。相当于y( ) 。
See also setTop( )topLeft()和topRight( ) 。
QPoint QRect.topLeft (self)
[
返回矩形的左上角的位置。
]($docs-qpoint.html)
See also setTopLeft( )top()和left( ) 。
QPoint QRect.topRight (self)
[
返回矩形的右上角的位置。
]($docs-qpoint.html)
请注意,由于历史原因,该函数返回QPoint(left()+width()-1 ,top())。
See also setTopRight( )top()和right( ) 。
QRect.translate (self, int dx, int dy)
移动矩形dx沿x轴和dy沿着y轴,相对于当前位置。正值移动矩形向右和向下。
See also moveTopLeft( )moveTo()和translated( ) 。
QRect.translate (self, QPoint p)
这是一个重载函数。
移动矩形offset。x()沿x轴和offset。y()沿着y轴,相对于当前位置。
QRect QRect.translated (self, int dx, int dy)
[
返回矩形的副本被翻译dx沿x轴和dy沿着y轴,相对于当前位置。正值移动矩形向右和向下。
]($docs-qrect.html)
QRect QRect.translated (self, QPoint p)
[
这是一个重载函数。
]($docs-qrect.html)
返回矩形的副本被翻译offset。x()沿x轴和offset。y()沿着y轴,相对于当前位置。
QRect QRect.unite (self, QRect r)
QRect QRect.united (self, QRect r)
[
返回此矩形的边框和给定rectangle。

这个函数中引入了Qt 4.2中。
]($docs-qrect.html)
See also intersected( ) 。
int QRect.width (self)
返回矩形的宽度。
See also setWidth( )height()和size( ) 。
int QRect.x (self)
返回矩形的左边缘的x坐标。相当于left( ) 。
See also setX( )y()和topLeft( ) 。
int QRect.y (self)
返回矩形的上边缘的y坐标。相当于top( ) 。
See also setY( )x()和topLeft( ) 。
QRect QRect.__and__ (self, QRect r)
[
int QRect.__bool__ (self)
int QRect.__contains__ (self, QPoint p)
int QRect.__contains__ (self, QRect r)
bool QRect.__eq__ (self, QRect r2)
]($docs-qrect.html)
QRect QRect.__iand__ (self, QRect r)
QRect QRect.__ior__ (self, QRect r)
[
bool QRect.__ne__ (self, QRect r2)
]($docs-qrect.html)
QRect QRect.__or__ (self, QRect r)
[
str QRect.__repr__ (self)
]($docs-qrect.html)
 
                         
                                

