diff options
Diffstat (limited to 'src/widgets/doc/snippets/customviewstyle/customviewstyle.cpp')
-rw-r--r-- | src/widgets/doc/snippets/customviewstyle/customviewstyle.cpp | 31 |
1 files changed, 31 insertions, 0 deletions
diff --git a/src/widgets/doc/snippets/customviewstyle/customviewstyle.cpp b/src/widgets/doc/snippets/customviewstyle/customviewstyle.cpp new file mode 100644 index 0000000000..7c690cab9f --- /dev/null +++ b/src/widgets/doc/snippets/customviewstyle/customviewstyle.cpp @@ -0,0 +1,31 @@ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause + +#include <QtWidgets> + +#include "../customstyle/customstyle.h" + +void CustomStyle::drawPrimitive(PrimitiveElement element, const QStyleOption *option, + QPainter *painter, const QWidget *widget) const +{ + +//![0] + switch (element) { + case (PE_PanelItemViewItem): { + painter->save(); + + QPoint topLeft = option->rect.topLeft(); + QPoint bottomRight = option->rect.topRight(); + QLinearGradient backgroundGradient(topLeft, bottomRight); + backgroundGradient.setColorAt(0.0, QColor(Qt::yellow).lighter(190)); + backgroundGradient.setColorAt(1.0, Qt::white); + painter->fillRect(option->rect, QBrush(backgroundGradient)); + + painter->restore(); + break; + } + default: + QProxyStyle::drawPrimitive(element, option, painter, widget); + } +//![0] +} |