I am overriding the paint(...) function of QStyledItemDelegate as follows. I just want to display a red cross in all cells of a column on a QTableView. (I am applying this delegate for 3rd column only) What is wrong with the code? I am not able to see the cross mark in the cell. Instead I can see a red spot at top left corner of the table
Qt Code:
  1. void CrossDelegate::paint(QPainter *painter,const QStyleOptionViewItem &option,const QModelIndex &index) const
  2. {
  3. painter->save();
  4. painter->setRenderHint(QPainter::Antialiasing, true);
  5. painter->setPen(QPen(Qt::red));
  6. painter->setBrush(option.palette.foreground());
  7. painter->drawLine(QPointF(0.0, 1.0) ,QPointF(1.0, 0.0) );
  8. painter->drawLine(QPointF(0.0, 0.0) ,QPointF(1.0, 1.0) );
  9. painter->restore();
  10. }
To copy to clipboard, switch view to plain text mode