Logo Search packages:      
Sourcecode: qt4-x11 version File versions

QRegion Class Reference

List of all members.

Detailed Description

The QRegion class specifies a clip region for a painter.

QRegion is used with QPainter::setClipRegion() to limit the paint area to what needs to be painted. There is also a QWidget::repaint() function that takes a QRegion parameter. QRegion is the best tool for reducing flicker.

A region can be created from a rectangle, an ellipse, a polygon or a bitmap. Complex regions may be created by combining simple regions using united(), intersected(), subtracted(), or xored() (exclusive or). You can move a region using translate().

You can test whether a region isEmpty() or if it contains() a QPoint or QRect. The bounding rectangle can be found with boundingRect().

The function rects() gives a decomposition of the region into rectangles.

Example of using complex regions:

        void MyWidget::paintEvent(QPaintEvent *)
            QRegion r1(QRect(100, 100, 200, 80),    // r1: elliptic region
            QRegion r2(QRect(100, 120, 90, 30));    // r2: rectangular region
            QRegion r3 = r1.intersected(r2);        // r3: intersection

            QPainter painter(this);
            ...                                     // paint clipped graphics

QRegion is an {implicitly shared class}.

Due to window system limitations, the whole coordinate space for a region is limited to the points between -32767 and 32767 on Windows 95/98/ME. You can circumvent this limitation by using a QPainterPath.

Definition at line 44 of file qregion.h.

Public Types

enum  RegionType { Rectangle, Ellipse }

Public Member Functions

QRect boundingRect () const
bool contains (const QRect &r) const
bool contains (const QPoint &p) const
QRegion eor (const QRegion &r) const
QRegion intersect (const QRegion &r) const
QRegion intersected (const QRegion &r) const
bool intersects (const QRect &r) const
bool intersects (const QRegion &r) const
bool isEmpty () const
const QRegion operator & (const QRegion &r) const
QRegionoperator &= (const QRegion &r)
 operator QVariant () const
bool operator!= (const QRegion &r) const
const QRegion operator+ (const QRegion &r) const
QRegionoperator+= (const QRegion &r)
const QRegion operator- (const QRegion &r) const
QRegionoperator-= (const QRegion &r)
QRegionoperator= (const QRegion &)
bool operator== (const QRegion &r) const
const QRegion operator^ (const QRegion &r) const
QRegionoperator^= (const QRegion &r)
const QRegion operator| (const QRegion &r) const
QRegionoperator|= (const QRegion &r)
 QRegion (const QBitmap &bitmap)
 QRegion (const QRegion &region)
 QRegion (const QPolygon &pa, Qt::FillRule fillRule=Qt::OddEvenFill)
 QRegion (const QRect &r, RegionType t=Rectangle)
 QRegion (int x, int y, int w, int h, RegionType t=Rectangle)
 QRegion ()
QVector< QRectrects () const
void setRects (const QRect *rect, int num)
QRegion subtract (const QRegion &r) const
QRegion subtracted (const QRegion &r) const
void translate (const QPoint &p)
void translate (int dx, int dy)
QRegion translated (const QPoint &p) const
QRegion translated (int dx, int dy) const
QRegion unite (const QRegion &r) const
QRegion united (const QRegion &r) const
QRegion xored (const QRegion &r) const
 ~QRegion ()

Private Member Functions

QRegion copy () const
void detach ()
void exec (const QByteArray &ba, int ver=0)

Static Private Member Functions

static void cleanUp (QRegionData *x)

Private Attributes

struct QRegionData * d

Static Private Attributes

static struct QRegionData shared_empty = {Q_ATOMIC_INIT(1), 0, 0, 0}


Q_GUI_EXPORT QDataStreamoperator<< (QDataStream &, const QRegion &)
Q_GUI_EXPORT QDataStreamoperator>> (QDataStream &, QRegion &)


struct  QRegionData

The documentation for this class was generated from the following files:

Generated by  Doxygen 1.6.0   Back to index