QRectF Class Reference

[QtCore module]

该QRectF类定义使用浮点精度在平面的矩形。More…

Methods

  • __init__ (self)
  • __init__ (self, QPointF atopLeft, QSizeF asize)
  • __init__ (self, QPointF atopLeft, QPointF abottomRight)
  • __init__ (self, float aleft, float atop, float awidth, float aheight)
  • __init__ (self, QRect r)
  • __init__ (self, QRectF)
  • adjust (self, float xp1, float yp1, float xp2, float yp2)
  • QRectF adjusted (self, float xp1, float yp1, float xp2, float yp2)
  • float bottom (self)
  • QPointF bottomLeft (self)
  • QPointF bottomRight (self)
  • QPointF center (self)
  • bool contains (self, QPointF p)
  • bool contains (self, QRectF r)
  • bool contains (self, float ax, float ay)
  • (float xp1, float yp1, float xp2, float yp2) getCoords (self)
  • (float ax, float ay, float aaw, float aah) getRect (self)
  • float height (self)
  • QRectF intersect (self, QRectF r)
  • QRectF intersected (self, QRectF r)
  • bool intersects (self, QRectF r)
  • bool isEmpty (self)
  • bool isNull (self)
  • bool isValid (self)
  • float left (self)
  • moveBottom (self, float pos)
  • moveBottomLeft (self, QPointF p)
  • moveBottomRight (self, QPointF p)
  • moveCenter (self, QPointF p)
  • moveLeft (self, float pos)
  • moveRight (self, float pos)
  • moveTo (self, float ax, float ay)
  • moveTo (self, QPointF p)
  • moveTop (self, float pos)
  • moveTopLeft (self, QPointF p)
  • moveTopRight (self, QPointF p)
  • QRectF normalized (self)
  • float right (self)
  • setBottom (self, float pos)
  • setBottomLeft (self, QPointF p)
  • setBottomRight (self, QPointF p)
  • setCoords (self, float xp1, float yp1, float xp2, float yp2)
  • setHeight (self, float ah)
  • setLeft (self, float pos)
  • setRect (self, float ax, float ay, float aaw, float aah)
  • setRight (self, float pos)
  • setSize (self, QSizeF s)
  • setTop (self, float pos)
  • setTopLeft (self, QPointF p)
  • setTopRight (self, QPointF p)
  • setWidth (self, float aw)
  • setX (self, float pos)
  • setY (self, float pos)
  • QSizeF size (self)
  • QRect toAlignedRect (self)
  • float top (self)
  • QPointF topLeft (self)
  • QPointF topRight (self)
  • QRect toRect (self)
  • translate (self, float dx, float dy)
  • translate (self, QPointF p)
  • QRectF translated (self, float dx, float dy)
  • QRectF translated (self, QPointF p)
  • QRectF unite (self, QRectF r)
  • QRectF united (self, QRectF r)
  • float width (self)
  • float x (self)
  • float y (self)

Special Methods

  • QRectF __and__ (self, QRectF r)
  • int __bool__ (self)
  • int __contains__ (self, QPointF p)
  • int __contains__ (self, QRectF r)
  • bool __eq__ (self, QRectF r2)
  • QRectF __iand__ (self, QRectF r)
  • QRectF __ior__ (self, QRectF r)
  • bool __ne__ (self, QRectF r2)
  • QRectF __or__ (self, QRectF r)
  • str __repr__ (self)

Detailed Description

这个类可以醃制。

该QRectF类定义使用浮点精度在平面的矩形。

一个矩形,通常表示为左上角和尺寸。一个QRectF的大小(宽度和高度)总是等于其形成的基础,它呈现的数学矩形。

甲QRectF可以用一组左,上,宽度和高度的整数,或者从一个被构造QPointQSize。下面的代码创建两个相同的矩形。

  1. QRectF r1(100, 200, 11, 16);
  2. QRectF r2([QPoint]($docs-qpoint.html)(100, 200), [QSize]($docs-qsize.html)(11, 16));

还有一个第三个构造函数从创建QRectFQRect和一个相应toRect( )函数返回一个QRect在此基础上矩形的值的对象(注意,在返回的矩形的坐标被四舍五入到最接近的整数。)

该QRectF类提供了返回的各种矩形坐标函数的集合,使操纵这些。 QRectF还提供功能,以矩形相对移动到不同的坐标。此外,还有一个moveTo( )函数,移动矩形,留下它的左上角在给定的坐标。或者,所述translate()函数使矩形给定的偏移量相对于当前位置,并且translated( )函数返回这个矩形的翻译件。

size( )函数返回rectange的尺寸为QSize。的尺寸也可以单独使用检索到的width()和height()函数。操控方面使用setSize( )setWidth()或setHeight()函数。可替换地,大小可以通过应用或功能设定矩形的坐标,例如被改变,setBottom()或setRight( ) 。

contains( )函数告诉一个给定的点是否是里面的矩形或没有了,intersects如果这个矩形相交与给定的矩形( )函数返回True (否则返回False ) 。该QRectF类还提供了intersected()函数返回相交的矩形,并在united( )函数将返回一个封装给定的矩形,这个矩形:

| QRectF Class Reference - 图1 | QRectF Class Reference - 图2 | | intersected() | united() |

isEmpty如果该矩形的宽度或高度小于或等于,大于0 , ()函数返回真。需要注意的是一个空矩形是无效的:在isValid如果宽度和高度大于0 ( )函数返回True。一个空矩形(isNull()== TRUE) ,另一方面,也将宽度和高度设置为0。

注意,由于该方法QRect和QRectF定义,一个空QRectF在本质上以同样的方式定义为QRect

最后,相比QRectF对象可以被串流播放,以及。

Rendering

当使用一个anti-aliased画家, QRectF的边界线将对称地在数学矩形的边界线的两侧呈现。但使用一个别名画家(默认值)时,其他规则。

然后,用一个像素宽的画笔绘制时QRectF的边界线将呈现给正确的和数学矩形的边界线下方。

当与两个像素宽画笔绘制边界线会由数学矩形被分割在中间。这将是这种情况时的笔被设置成偶数个像素,而与像素数为奇数的笔绘制,备用像素将呈现向右和数学矩形中的一个像素的情况下。

| QRectF Class Reference - 图3 | QRectF Class Reference - 图4 | | Logical representation | One pixel wide pen | | QRectF Class Reference - 图5 | QRectF Class Reference - 图6 | | Two pixel wide pen | Three pixel wide pen |

Coordinates

该QRectF类提供了返回的各种矩形坐标函数的集合,使操纵这些。 QRectF还提供功能,以矩形相对移动到不同的坐标。

例如:bottom( )setBottom()和moveBottom( )函数:bottom()返回矩形的底边的y坐标,setBottom()设置矩形的底边给定的y坐标(它可能会改变高度,但决不会改变矩形的顶边)和moveBottom( )移动整个矩形垂直,使矩形的底边在给定的y坐标和尺寸不变。

QRectF Class Reference - 图7

另外,也可以使用偏移量添加到该矩形的坐标adjust()函数,以及检索使用基于原来的1调整一个新的矩形的adjusted()函数。如果其中的宽度和高度为负时,用normalized()函数来检索其中的角部被交换的矩形。

此外, QRectF提供getCoords()函数,其提取的矩形的左上角和右下角的位置,并且getRect( )函数,它提取矩形的左上角,宽度和高度。使用setCoords()和setRect( )函数来处理矩形的坐标和尺寸一气呵成。


Method Documentation

  1. QRectF.__init__ (self)

构造一个空矩形。

See also isNull( ) 。

  1. QRectF.__init__ (self, QPointF atopLeft, QSizeF asize)

构造一个矩形与给定topLeft角部和所述定size

See also setTopLeft()和setSize( ) 。

  1. QRectF.__init__ (self, QPointF atopLeft, QPointF abottomRight)

构造一个矩形与给定topLeftbottomRight角落。

此功能被引入Qt的4.3 。

See also setTopLeft()和setBottomRight( ) 。

  1. QRectF.__init__ (self, float aleft, float atop, float awidth, float aheight)

构造一个矩形(xy)作为它的左上角和给定的widthheight

See also setRect( ) 。

  1. QRectF.__init__ (self, QRect r)

构造一个QRectF从给定的矩形QRect rectangle

See also toRect( ) 。

  1. QRectF.__init__ (self, QRectF)
  1. QRectF.adjust (self, float xp1, float yp1, float xp2, float yp2)

添加dx1dy1dx2dy2分别以矩形的现有的坐标。

See also adjusted()和setRect( ) 。

  1. QRectF QRectF.adjusted (self, float xp1, float yp1, float xp2, float yp2)

[

返回一个新的矩形dx1dy1dx2dy2分别加入到这个矩形的现有坐标。

]($docs-qrectf.html)

See also adjust( ) 。

  1. float QRectF.bottom (self)

返回矩形的底边的y坐标。

See also setBottom( )bottomLeft()和bottomRight( ) 。

  1. QPointF QRectF.bottomLeft (self)

[

返回矩形的左下角的位置。

]($docs-qpointf.html)

See also setBottomLeft( )bottom()和left( ) 。

  1. QPointF QRectF.bottomRight (self)

[

返回矩形的右下角的位置。

]($docs-qpointf.html)

See also setBottomRight( )bottom()和right( ) 。

  1. QPointF QRectF.center (self)

[

返回矩形的中心点。

]($docs-qpointf.html)

See also moveCenter( ) 。

  1. bool QRectF.contains (self, QPointF p)

返回True如果给定的point是内部或矩形的边缘,否则返回False 。

See also intersects( ) 。

  1. bool QRectF.contains (self, QRectF r)

这是一个重载函数。

返回True如果点(xy)是内部或矩形的边缘,否则返回False 。

  1. bool QRectF.contains (self, float ax, float ay)

这是一个重载函数。

返回True如果给定的rectangle是这个矩形里面,否则返回False 。

  1. (float xp1, float yp1, float xp2, float yp2) QRectF.getCoords (self)

提取矩形的左上角的位置x1y1和右下角为的位置x2y2

See also setCoords()和getRect( ) 。

  1. (float ax, float ay, float aaw, float aah) QRectF.getRect (self)

提取矩形的左上角的位置xy,其尺寸widthheight

See also setRect()和getCoords( ) 。

  1. float QRectF.height (self)

返回该矩形的高度。

See also setHeight( )width()和size( ) 。

  1. QRectF QRectF.intersect (self, QRectF r)

  1. QRectF QRectF.intersected (self, QRectF r)

[

返回此矩形的交集和给定的rectangle。需要注意的是r.intersected(s)相当于r & s

QRectF Class Reference - 图8

这个函数中引入了Qt 4.2中。

]($docs-qrectf.html)

See also intersects( )united()和operator&=( ) 。

  1. bool QRectF.intersects (self, QRectF r)

如果这个矩形相交与给定的,则返回Truerectangle(即它们之间有重叠的非空白区域) ,否则返回False 。

相交的矩形可使用检索到的intersected()函数。

See also contains( ) 。

  1. bool QRectF.isEmpty (self)

返回True如果矩形为空,否则返回False 。

一个空矩形有width()\u003c = 0或height()\u003c = 0 。一个空矩形是无效的(即,参考isEmpty ( ) == !isValid())。

使用normalized()函数来检索其中的角部被交换的矩形。

See also isNull( )isValid()和normalized( ) 。

  1. bool QRectF.isNull (self)

返回True如果矩形为空矩形,否则返回False 。

空矩形具有的宽度和高度设置为0。一个空的矩形也是空的,因此无效。

See also isEmpty()和isValid( ) 。

  1. bool QRectF.isValid (self)

返回True如果矩形是有效的,否则返回False 。

一个有效的矩形有一个width()\u003e 0和height()\u003e 0 。请注意,就像十字路口不平凡的操作没有定义无效矩形。一个有效的矩形不为空(即参考isValid ( ) == !isEmpty())。

See also isNull( )isEmpty()和normalized( ) 。

  1. float QRectF.left (self)

返回矩形的左边缘的x坐标。相当于x( ) 。

See also setLeft( )topLeft()和bottomLeft( ) 。

  1. QRectF.moveBottom (self, float pos)

移动矩形垂直,使矩形的底边在给定的y协调。矩形的尺寸是不变的。

See also bottom( )setBottom()和moveTop( ) 。

  1. QRectF.moveBottomLeft (self, QPointF p)

移动矩形,留下左下角在给定的position。矩形的尺寸是不变的。

See also setBottomLeft( )moveBottom()和moveLeft( ) 。

  1. QRectF.moveBottomRight (self, QPointF p)

移动矩形,留下右下角的定position。矩形的尺寸是不变的。

See also setBottomRight( )moveBottom()和moveRight( ) 。

  1. QRectF.moveCenter (self, QPointF p)

移动矩形,而使中心点在给定的position。矩形的尺寸是不变的。

See also center( ) 。

  1. QRectF.moveLeft (self, float pos)

水平移动矩形,使矩形的左边缘在给定的x协调。矩形的尺寸是不变的。

See also left( )setLeft()和moveRight( ) 。

  1. QRectF.moveRight (self, float pos)

水平移动矩形,使矩形的右边缘在给定的x协调。矩形的尺寸是不变的。

See also right( )setRight()和moveLeft( ) 。

  1. QRectF.moveTo (self, float ax, float ay)

移动矩形,留下左上角的指定位置(xy) 。矩形的尺寸是不变的。

See also translate()和moveTopLeft( ) 。

  1. QRectF.moveTo (self, QPointF p)

这是一个重载函数。

移动矩形,留下左上角在给定的position

  1. QRectF.moveTop (self, float pos)

移动矩形垂直,使矩形的顶线在给定的y协调。矩形的尺寸是不变的。

See also top( )setTop()和moveBottom( ) 。

  1. QRectF.moveTopLeft (self, QPointF p)

移动矩形,留下左上角在给定的position。矩形的尺寸是不变的。

See also setTopLeft( )moveTop()和moveLeft( ) 。

  1. QRectF.moveTopRight (self, QPointF p)

移动矩形,留下右上角的定position。矩形的尺寸是不变的。

See also setTopRight( )moveTop()和moveRight( ) 。

  1. QRectF QRectF.normalized (self)

[

返回一个归一化的矩形,即,具有一个非负的宽度和高度的矩形。

]($docs-qrectf.html)

If width()\u003c 0的函数交换的左右角部,并且交换的顶部和底部边角,如果height()\u003c 0 。

See also isValid()和isEmpty( ) 。

  1. float QRectF.right (self)

返回矩形的右边缘的x坐标。

See also setRight( )topRight()和bottomRight( ) 。

  1. QRectF.setBottom (self, float pos)

设置的矩形的底部边缘与给定的y协调。可能会改变高度,但决不会改变矩形的上边缘。

See also bottom()和moveBottom( ) 。

  1. QRectF.setBottomLeft (self, QPointF p)

设置矩形的左下角给定的position。可以改变大小,但决不会改变矩形的右上角。

See also bottomLeft()和moveBottomLeft( ) 。

  1. QRectF.setBottomRight (self, QPointF p)

设置矩形的右下角为给定的position。可以改变大小,但决不会改变矩形的左上角。

See also bottomRight()和moveBottomRight( ) 。

  1. QRectF.setCoords (self, float xp1, float yp1, float xp2, float yp2)

设置矩形的左上角的坐标为(x1y1)和其右下角的坐标(x2y2) 。

See also getCoords()和setRect( ) 。

  1. QRectF.setHeight (self, float ah)

设置了矩形的高度为给定的height。底部边缘被改变,但不顶一个。

See also height()和setSize( ) 。

  1. QRectF.setLeft (self, float pos)

设置了矩形的左边缘到给定的x协调。可能会改变宽度,但决不会改变矩形的右边缘。

相当于setX( ) 。

See also left()和moveLeft( ) 。

  1. QRectF.setRect (self, float ax, float ay, float aaw, float aah)

设置矩形的左上角的坐标为(xy) ,并且其大小为给定的widthheight

See also getRect()和setCoords( ) 。

  1. QRectF.setRight (self, float pos)

设置了矩形的右边缘到给定的x协调。可能会改变宽度,但决不会改变矩形的左边缘。

See also right()和moveRight( ) 。

  1. QRectF.setSize (self, QSizeF s)

设置了矩形的大小给定的size。在左上角不移动。

See also size( )setWidth()和setHeight( ) 。

  1. QRectF.setTop (self, float pos)

设置了矩形的顶边到给定的y协调。可能会改变高度,但决不会改变矩形的底边。

相当于setY( ) 。

See also top()和moveTop( ) 。

  1. QRectF.setTopLeft (self, QPointF p)

设置的矩形的左上角的给定position。可以改变大小,但决不会改变矩形的右下角。

See also topLeft()和moveTopLeft( ) 。

  1. QRectF.setTopRight (self, QPointF p)

设置矩形的右上角,以给定的position。可以改变大小,但决不会改变矩形的左下角。

See also topRight()和moveTopRight( ) 。

  1. QRectF.setWidth (self, float aw)

设置了矩形的宽度与给定width。右边缘被改变,但不是左1 。

See also width()和setSize( ) 。

  1. QRectF.setX (self, float pos)

设置了矩形的左边缘到给定的x协调。可能会改变宽度,但决不会改变矩形的右边缘。

相当于setLeft( ) 。

See also x( )setY()和setTopLeft( ) 。

  1. QRectF.setY (self, float pos)

设置了矩形的顶边到给定的y协调。可能会改变高度,但决不会改变矩形的底边。

相当于setTop( ) 。

See also y( )setX()和setTopLeft( ) 。

  1. QSizeF QRectF.size (self)

[

返回矩形的大小。

]($docs-qsizef.html)

See also setSize( )width()和height( ) 。

  1. QRect QRectF.toAlignedRect (self)

返回QRect基于这个矩形是可能的最小整数矩形完全包含此矩形的值。

此功能被引入Qt的4.3 。

See also toRect( ) 。

  1. float QRectF.top (self)

返回矩形的上边缘的y坐标。相当于y( ) 。

See also setTop( )topLeft()和topRight( ) 。

  1. QPointF QRectF.topLeft (self)

[

返回矩形的左上角的位置。

]($docs-qpointf.html)

See also setTopLeft( )top()和left( ) 。

  1. QPointF QRectF.topRight (self)

[

返回矩形的右上角的位置。

]($docs-qpointf.html)

See also setTopRight( )top()和right( ) 。

  1. QRect QRectF.toRect (self)

返回QRect在此基础上矩形的值。请注意,在返回的矩形坐标四舍五入到最接近的整数。

See also QRectF()和toAlignedRect( ) 。

  1. QRectF.translate (self, float dx, float dy)

移动矩形dx沿x轴和dy沿着y轴,相对于当前位置。正值移动矩形向右,向下。

See also moveTopLeft( )moveTo()和translated( ) 。

  1. QRectF.translate (self, QPointF p)

这是一个重载函数。

移动矩形offsetx()沿x轴和offsety()沿着y轴,相对于当前位置。

  1. QRectF QRectF.translated (self, float dx, float dy)

[

返回矩形的副本被翻译dx沿x轴和dy沿着y轴,相对于当前位置。正值移动矩形向右和向下。

]($docs-qrectf.html)

See also translate( ) 。

  1. QRectF QRectF.translated (self, QPointF p)

[

这是一个重载函数。

]($docs-qrectf.html)

返回矩形的副本被翻译offsetx()沿x轴和offsety()沿着y轴,相对于当前位置。

  1. QRectF QRectF.unite (self, QRectF r)

  1. QRectF QRectF.united (self, QRectF r)

[

返回此矩形的边框和给定rectangle

QRectF Class Reference - 图9

这个函数中引入了Qt 4.2中。

]($docs-qrectf.html)

See also intersected( ) 。

  1. float QRectF.width (self)

返回矩形的宽度。

See also setWidth( )height()和size( ) 。

  1. float QRectF.x (self)

返回矩形的左边缘的x坐标。相当于left( ) 。

See also setX( )y()和topLeft( ) 。

  1. float QRectF.y (self)

返回矩形的上边缘的y坐标。相当于top( ) 。

See also setY( )x()和topLeft( ) 。

  1. QRectF QRectF.__and__ (self, QRectF r)

[

  1. int QRectF.__bool__ (self)
  1. int QRectF.__contains__ (self, QPointF p)
  1. int QRectF.__contains__ (self, QRectF r)
  1. bool QRectF.__eq__ (self, QRectF r2)

]($docs-qrectf.html)

  1. QRectF QRectF.__iand__ (self, QRectF r)

  1. QRectF QRectF.__ior__ (self, QRectF r)

[

  1. bool QRectF.__ne__ (self, QRectF r2)

]($docs-qrectf.html)

  1. QRectF QRectF.__or__ (self, QRectF r)

[

  1. str QRectF.__repr__ (self)

]($docs-qrectf.html)