Is that what you wanted?

tree.png

Qt Code:
  1. void ProgressBarDelegate::paint( QPainter* painter, const QStyleOptionViewItem& option, const QModelIndex& index ) const
  2. {
  3. if( index.column() == 1 )
  4. {
  5. if( option.state & QStyle::State_Selected )
  6. {
  7. painter->fillRect( option.rect, option.palette.highlight() );
  8. }
  9.  
  10. int progress = index.data().toInt();
  11.  
  12. QStyleOptionProgressBar progressBarOption;
  13. progressBarOption.rect = option.rect;
  14. progressBarOption.rect.setTop( option.rect.top() + 1 );
  15. progressBarOption.rect.setHeight( option.rect.height() - 2 );
  16. progressBarOption.minimum = 0;
  17. progressBarOption.maximum = 100;
  18. progressBarOption.progress = progress;
  19. progressBarOption.text = QString::number(progress) + "%";
  20. progressBarOption.textVisible = true;
  21. progressBarOption.textAlignment = Qt::AlignCenter;
  22.  
  23. QApplication::style()->drawControl(QStyle::CE_ProgressBar, &progressBarOption, painter);
  24. }
  25. else
  26. {
  27. QStyledItemDelegate::paint(painter, option, index);
  28. }
  29. }
To copy to clipboard, switch view to plain text mode