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
doc_src_qt4-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
<
QStyleOptionFocusRect
>
5
#
include
<
QPainter
>
6
7
class
MyWidget
:
public
QWidget
8
{
9
Q_OBJECT
10
11
public
:
12
void
paintEvent
(
QPaintEvent
*
event
)
override
;
13
};
14
15
void
snippet
(
const
QStyleOptionFocusRect *option)
16
{
17
//! [0]
18
const
QStyleOptionFocusRect *focusRectOption =
19
qstyleoption_cast<
const
QStyleOptionFocusRect *>(option);
20
if
(focusRectOption) {
21
//...
22
}
23
//! [0]
24
}
25
26
//! [1]
27
void
MyWidget
::
paintEvent
(QPaintEvent *event)
28
{
29
QPainter painter(
this
);
30
//...
31
32
QStyleOptionFocusRect option;
33
option.initFrom(
this
);
34
option.backgroundColor = palette().color(QPalette::Window);
35
36
style()->drawPrimitive(QStyle::PE_FrameFocusRect, &option, &painter,
37
this
);
38
}
39
//! [1]
MyWidget
[24]
Definition
src_corelib_kernel_qobject.cpp:264
MyWidget::paintEvent
void paintEvent(QPaintEvent *event) override
This event handler can be reimplemented in a subclass to receive paint events passed in event.
snippet
void snippet(const QStyleOptionFocusRect *option)
Definition
doc_src_qt4-styles.cpp:15
qtbase
src
widgets
doc
snippets
code
doc_src_qt4-styles.cpp
Generated on
for Qt by
1.14.0