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