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
customviewstyle.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 <QtWidgets>
5
7
8void CustomStyle::drawPrimitive(PrimitiveElement element, const QStyleOption *option,
9 QPainter *painter, const QWidget *widget) const
10{
11
13 switch (element) {
14 case (PE_PanelItemViewItem): {
15 painter->save();
16
17 QPoint topLeft = option->rect.topLeft();
18 QPoint bottomRight = option->rect.topRight();
19 QLinearGradient backgroundGradient(topLeft, bottomRight);
20 backgroundGradient.setColorAt(0.0, QColor(Qt::yellow).lighter(190));
21 backgroundGradient.setColorAt(1.0, Qt::white);
22 painter->fillRect(option->rect, QBrush(backgroundGradient));
23
25 break;
26 }
27 default:
29 }
31}
void drawPrimitive(PrimitiveElement element, const QStyleOption *option, QPainter *painter, const QWidget *widget) const override
[2]
\inmodule QtGui
Definition qbrush.h:30
The QColor class provides colors based on RGB, HSV or CMYK values.
Definition qcolor.h:31
\inmodule QtGui
Definition qbrush.h:394
The QPainter class performs low-level painting on widgets and other paint devices.
Definition qpainter.h:46
void restore()
Restores the current painter state (pops a saved state off the stack).
void save()
Saves the current painter state (pushes the state onto a stack).
void fillRect(const QRectF &, const QBrush &)
Fills the given rectangle with the brush specified.
\inmodule QtCore\reentrant
Definition qpoint.h:25
void drawPrimitive(PrimitiveElement element, const QStyleOption *option, QPainter *painter, const QWidget *widget=nullptr) const override
\reimp
The QStyleOption class stores the parameters used by QStyle functions.
@ PE_PanelItemViewItem
Definition qstyle.h:153
The QWidget class is the base class of all user interface objects.
Definition qwidget.h:99
QOpenGLWidget * widget
[1]
@ white
Definition qnamespace.h:31
@ yellow
Definition qnamespace.h:40
GLuint GLenum option
QPainter painter(this)
[7]