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
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
6#include "../customstyle/customstyle.h"
7
8void CustomStyle::drawPrimitive(PrimitiveElement element, const QStyleOption *option,
9 QPainter *painter, const QWidget *widget) const
10{
11
12 //![0]
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
24 painter->restore();
25 break;
26 }
27 default:
28 QProxyStyle::drawPrimitive(element, option, painter, widget);
29 }
30 //![0]
31}
void drawPrimitive(PrimitiveElement element, const QStyleOption *option, QPainter *painter, const QWidget *widget) const override
[2]