C++ (Qt)void ProgressBarDelegate::paint( QPainter *painter, const QStyleOptionViewItem &option, const QModelIndex &index ) const{ if( !index.isValid() ) return; painter->save(); int val = index.data( Qt::DisplayRole ).toInt(); if( val ) { QStyleOptionProgressBar opt; opt.state = option.state; opt.direction = option.direction; opt.rect = option.rect; opt.fontMetrics = option.fontMetrics; opt.palette = option.palette; opt.minimum = 0; opt.maximum = 100; opt.progress = val; opt.textAlignment = Qt::AlignCenter; opt.textVisible = true; opt.text = QString( "%1 %" ).arg( val ); QProgressBar bar; QApplication::style()->drawControl( QStyle::CE_ProgressBar, &opt, painter, &bar ); } painter->restore();}