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
widgetdelegate.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 <QtGui>
5
6#include "widgetdelegate.h"
7
9void WidgetDelegate::paint(QPainter *painter, const QStyleOptionViewItem &option,
10 const QModelIndex &index) const
11{
12 if (index.column() == 1) {
13 int progress = index.data().toInt();
14
15 QStyleOptionProgressBar progressBarOption;
16 progressBarOption.rect = option.rect;
17 progressBarOption.minimum = 0;
18 progressBarOption.maximum = 100;
19 progressBarOption.progress = progress;
20 progressBarOption.text = QString::number(progress) + "%";
21 progressBarOption.textVisible = true;
22
24 &progressBarOption, painter);
25 } else
27
29}
static QStyle * style()
Returns the application's style object.
\inmodule QtCore
The QPainter class performs low-level painting on widgets and other paint devices.
Definition qpainter.h:46
static QString number(int, int base=10)
This is an overloaded member function, provided for convenience. It differs from the above function o...
Definition qstring.cpp:8084
\variable QStyleOptionButton::features
@ CE_ProgressBar
Definition qstyle.h:185
void paint(QPainter *painter, const QStyleOptionViewItem &option, const QModelIndex &index) const override
Renders the delegate using the given painter and style option for the item specified by index.
GLuint index
[2]
GLuint GLenum option
QPainter painter(this)
[7]