summaryrefslogtreecommitdiff
path: root/doc/src/snippets/code/src_gui_painting_qregion.cpp
blob: 6c5dfa5e47a67a310f3072ebe240b9cf3acf0c05 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
//! [0]
void MyWidget::paintEvent(QPaintEvent *)
{
    QRegion r1(QRect(100, 100, 200, 80),    // r1: elliptic region
               QRegion::Ellipse);
    QRegion r2(QRect(100, 120, 90, 30));    // r2: rectangular region
    QRegion r3 = r1.intersected(r2);        // r3: intersection

    QPainter painter(this);
    painter.setClipRegion(r3);
    ...                                     // paint clipped graphics
}
//! [0]