17void WidgetDelegate::paint(QPainter *painter,
const QStyleOptionViewItem &option,
18 const QModelIndex &index)
const
20 if (index.column() == 1) {
21 int progress = index.data().toInt();
23 QStyleOptionProgressBar progressBarOption;
24 progressBarOption.rect = option.rect;
25 progressBarOption.minimum = 0;
26 progressBarOption.maximum = 100;
27 progressBarOption.progress = progress;
28 progressBarOption.text = QString::number(progress) +
"%";
29 progressBarOption.textVisible =
true;
31 QApplication::style()->drawControl(QStyle::CE_ProgressBar,
32 &progressBarOption, painter);
34 QStyledItemDelegate::paint(painter, option, index);