Qt
Internal/Contributor docs for the Qt SDK. Note: These are NOT official API docs; those are found at https://doc.qt.io/
Loading...
Searching...
No Matches
src_gui_painting_qregion.cpp
Go to the documentation of this file.
1// Copyright (C) 2016 The Qt Company Ltd.
2// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
3#include <QPaintEvent>
4#include <QPainter>
5
7struct MyWidget : public QPaintDevice
8{
9 void paintEvent(QPaintEvent *);
10};
11
12//! [0]
13void MyWidget::paintEvent(QPaintEvent *)
14{
15 QRegion r1(QRect(100, 100, 200, 80), // r1: elliptic region
16 QRegion::Ellipse);
17 QRegion r2(QRect(100, 120, 90, 30)); // r2: rectangular region
18 QRegion r3 = r1.intersected(r2); // r3: intersection
19
20 QPainter painter(this);
21 painter.setClipRegion(r3);
22 // ... // paint clipped graphics
23}
24//! [0]
25
26} // src_gui_painting_qregion