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
6
namespace
src_gui_painting_qregion
{
7
struct
MyWidget
:
public
QPaintDevice
8
{
9
void
paintEvent
(QPaintEvent *);
10
};
11
12
//! [0]
13
void
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
src_gui_painting_qregion
Definition
src_gui_painting_qregion.cpp:6
src_gui_painting_qregion::MyWidget
Definition
src_gui_painting_qregion.cpp:8
src_gui_painting_qregion::MyWidget::paintEvent
void paintEvent(QPaintEvent *)
[0]
Definition
src_gui_painting_qregion.cpp:13
qtbase
src
gui
doc
snippets
code
src_gui_painting_qregion.cpp
Generated on
for Qt by
1.14.0