-
Notifications
You must be signed in to change notification settings - Fork 1
/
ProgressDelegate.h
36 lines (29 loc) · 951 Bytes
/
ProgressDelegate.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
#ifndef PROGRESSDELEGATE_H
#define PROGRESSDELEGATE_H
#include <QMainWindow>
#include <QStyledItemDelegate>
#include <QApplication>
class ProgressDelegate : public QStyledItemDelegate
{
Q_OBJECT
public:
ProgressDelegate(QObject *parent = 0)
: QStyledItemDelegate(parent)
{
}
void paint(QPainter *painter, const QStyleOptionViewItem &option,
const QModelIndex &index) const
{
QStyleOptionProgressBar progressBarOption;
progressBarOption.rect = option.rect;
progressBarOption.minimum = 0;
progressBarOption.maximum = 100;
progressBarOption.progress = index.data().toInt();
progressBarOption.text =
QString::number(progressBarOption.progress) + "%";
progressBarOption.textVisible = true;
QApplication::style()->drawControl(QStyle::CE_ProgressBar,
&progressBarOption, painter);
}
};
#endif // PROGRESSDELEGATE_H