24 #include <QApplication>
26 #include <QProgressBar>
30 void ProgressbarDelegate::paint(QPainter* painter,
const QStyleOptionViewItem&
option,
const QModelIndex&
index)
const
32 if (
index.column() == 3)
34 int progress =
index.data().toInt();
36 QStyleOptionProgressBar progressBarOption;
37 progressBarOption.rect =
option.rect;
38 progressBarOption.minimum = 0;
39 progressBarOption.maximum = 100;
40 progressBarOption.progress = progress;
41 progressBarOption.text = QString::number(progress) +
"%";
42 progressBarOption.textVisible =
true;
43 QApplication::style()->drawControl(QStyle::CE_ProgressBar,
44 &progressBarOption, painter);