Qt
Internal/Contributor docs for the Qt SDK. <b>Note:</b> These are NOT official API docs; those are found <a href='https://doc.qt.io/'>here</a>.
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
8class MyWidget : public QWidget
9{
10protected:
11 void paintEvent(QPaintEvent *event) override;
13
14};
15
17void MyWidget::paintEvent(QPaintEvent * /* event */)
19{
21 QPainter painter(this);
23
25 option.initFrom(this);
26 option.backgroundColor = palette().color(QPalette::Background);
27
31}
33
36{
40
42 option.initFrom(this);
43 option.backgroundColor = palette().color(QPalette::Background);
44
48}
50
51int main()
52{
53 return 0;
54}
void paintEvent2(QPaintEvent *event)
[1]
Definition styles.cpp:34
void paintEvent(QPaintEvent *event) override
[0]
The QPaintEvent class contains event parameters for paint events.
Definition qevent.h:486
The QPainter class performs low-level painting on widgets and other paint devices.
Definition qpainter.h:46
const QColor & color(ColorGroup cg, ColorRole cr) const
Returns the color in the specified color group, used for the given color role.
Definition qpalette.h:67
\variable QStyleOption::palette
void initFrom(const QWidget *w)
The QStylePainter class is a convenience class for drawing QStyle elements inside a widget.
@ PE_FrameFocusRect
Definition qstyle.h:106
virtual void drawPrimitive(PrimitiveElement pe, const QStyleOption *opt, QPainter *p, const QWidget *w=nullptr) const =0
Draws the given primitive element with the provided painter using the style options specified by opti...
The QWidget class is the base class of all user interface objects.
Definition qwidget.h:99
QPalette palette
the widget's palette
Definition qwidget.h:132
QStyle * style() const
Definition qwidget.cpp:2600
struct _cl_event * event
GLuint GLenum option
QPainter painter(this)
[7]
int main()
[6]
Definition styles.cpp:51