using the stardelegate example I made a simple paint function to make a file with extension "001" blue:
Qt Code:
  1. void StarDelegate::paint(QPainter *painter, const QStyleOptionViewItem &option,
  2. const QModelIndex &index) const
  3. {
  4. QStyleOptionViewItem opt = option;
  5. if (index.column() == 0)
  6. {
  7. QString name = index.model()->data(index, Qt::DisplayRole).toString();
  8. if (QFileInfo(name).suffix() == "001")
  9. {
  10. painter->setPen(QColor(0, 0, 255, 255));
  11. QFont f = painter->font();
  12. painter->setFont(f);
  13. opt.font.setItalic(true);
  14. }
  15. }
  16. QStyledItemDelegate::paint(painter, opt, index);
  17. }
To copy to clipboard, switch view to plain text mode 
The files with 001 are displayed in italics but not in blue. So the selection and adapting opt works, but setPen doesn't. Why not? thanks.