Hi there,

I want to put QProgressBar into tableview, so i made my own delegate based on QStyledItemDelegate. In documentation of QStyledItemDelegate its written, that it should work with defined style sheet. I defined it in designer. It works for progressbar, that is not in list, but i doesn't work in qtableview.
My enviroment: QT 4.6.3 on Kubuntu 10.04 amd64.

Anyone knows solution on that?

code of my paint function:
Qt Code:
  1. void CProgressbarDelegate::paint(QPainter *painter, const QStyleOptionViewItem &option, const QModelIndex &index) const
  2. {
  3. QStyleOptionProgressBar oProgressBarStyle;
  4. oProgressBarStyle.rect = option.rect;
  5. oProgressBarStyle.minimum = 0;
  6. oProgressBarStyle.maximum = 100;
  7. oProgressBarStyle.progress = index.model()->data(index, Qt::DisplayRole).toInt();
  8. oProgressBarStyle.textAlignment = Qt::AlignHCenter;
  9. oProgressBarStyle.textVisible = true;
  10. oProgressBarStyle.text = QString::number(oProgressBarStyle.progress)+"%";
  11.  
  12. QApplication::style()->drawControl(QStyle::CE_ProgressBar, &oProgressBarStyle, painter, m_pWidget);
  13. }
To copy to clipboard, switch view to plain text mode 

m_pWidget was QTableView pointer and MainWindow pointer, even without QWidget it doesn't work.