Qt
Internal/Contributor docs for the Qt SDK. Note: These are NOT official API docs; those are found at https://doc.qt.io/
Toggle main menu visibility
Loading...
Searching...
No Matches
styles.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
4
#
include
<
QStyleOption
>
5
#
include
<
QStylePainter
>
6
#
include
<
QWidget
>
7
8
class
MyWidget
:
public
QWidget
9
{
10
protected
:
11
void
paintEvent
(QPaintEvent *event)
override
;
12
void
paintEvent2
(QPaintEvent *event);
13
14
};
15
16
//! [0] //! [1]
17
void
MyWidget
::
paintEvent
(QPaintEvent *
/* event */
)
18
//! [0]
19
{
20
//! [2]
21
QPainter painter(
this
);
22
//! [2]
23
24
QStyleOptionFocusRect option;
25
option.initFrom(
this
);
26
option.backgroundColor = palette().color(QPalette::Window);
27
28
//! [3]
29
style()->drawPrimitive(QStyle::PE_FrameFocusRect, &option, &painter,
this
);
30
//! [3]
31
}
32
//! [1]
33
34
void
MyWidget
::
paintEvent2
(QPaintEvent *
/* event */
)
35
//! [4]
36
{
37
//! [4] //! [5] //! [6]
38
QStylePainter painter(
this
);
39
//! [5]
40
41
QStyleOptionFocusRect option;
42
option.initFrom(
this
);
43
option.backgroundColor = palette().color(QPalette::Window);
44
45
//! [7]
46
painter.drawPrimitive(QStyle::PE_FrameFocusRect, option);
47
//! [7]
48
}
49
//! [6]
50
51
int
main
()
52
{
53
return
0;
54
}
MyWidget
[24]
Definition
src_corelib_kernel_qobject.cpp:264
MyWidget::paintEvent2
void paintEvent2(QPaintEvent *event)
[1]
Definition
styles.cpp:34
MyWidget::paintEvent
void paintEvent(QPaintEvent *event) override
This event handler can be reimplemented in a subclass to receive paint events passed in event.
main
int main()
[open]
Definition
doc_src_objecttrees.cpp:7
qtbase
src
widgets
doc
snippets
styles
styles.cpp
Generated on
for Qt by
1.18.0