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
7class MyWidget : public QWidget
8{
10
11public:
13};
14
15void 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]
27void 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]
void paintEvent(QPaintEvent *event) override
This event handler can be reimplemented in a subclass to receive paint events passed in event.
void snippet(const QStyleOptionFocusRect *option)