StupidBeauty
Read times:1576Posted at:Sat Dec 10 01:02:33 2011
- no title specified

Qt4.7文档翻译:QRegion类参考,QRegion Class Reference

详细描述

QRegion类为绘图者(painter)指定一個裁剪区域(clip region)。

QRegion是与 QPainter::setClipRegion ()配合使用的,用来将要绘制的東西限制在一個区域。还有一個 QWidget::repaint ()函数,它会将一個QRegion 作为参数來使用。QRegion是用来将重绘的屏幕區域最小化的最佳工具。

这個类不适合于为渲染过程构造特定形状,尤其是构造轮廓。使用 QPainterPath 来创建要用于 QPainter 的路径(paths)和形状。

QRegion是一個隐式共享( implicitly shared 类。

创建及使用区域

一個區域可创建自一個矩形、椭圆、多边形或位圖。复杂的区域可通过使用 united ()、 intersected ()、 subtracted ()或 xored () (exclusive or)(异或)来组合简单的区域而创建。妳可使用 translate ()来移动一個區域。

妳可以测验某個區域是否为空( isEmpty ())、是否包含( contains ())一個点( QPoint )或一個□( QRect )。可使用来获取它的边界□(bounding rectangle)( boundingRect ())。

rects ()函数返回的是将这個區域分解(decomposition)成□中的區域之后的结果。

使用复杂區域的示例:

void MyWidget :: paintEvent( QPaintEvent * )

{

QRegion r1( QRect ( 100 , 100 , 200 , 80 ) , // r1:椭圆區域

QRegion :: Ellipse);

QRegion r2( QRect ( 100 , 120 , 90 , 30 )); // r2:□區域

QRegion r3 = r1 . intersected(r2); // r3:交集

QPainter painter( this );

painter . setClipRegion(r3);

... //绘制剪裁过之后的图形

}

附加的许可证信息

……

参考 QPainter::setClipRegion () QPainter::setClipRect () QPainterPath

Your opinions
Your name:Email:Website url:Opinion content:
- no title specified

HxLauncher: Launch Android applications by voice commands