Hi,

Am trying to subclass an item Delegate (to display images on QTableView cells),
I reimplemented QItemDelegate::paint() and QItemDelegate::sizeHint().
When I tested it, the function paint() is not called at all.
Here is my code


Qt Code:
  1. class ItemImageDelegate : public QItemDelegate
  2. {
  3. Q_OBJECT
  4.  
  5. public:
  6. ItemImageDelegate(QObject*) ;
  7.  
  8. void paint(QPainter * painter, const QStyleOptionViewItem & option, const QModelIndex & index) const;
  9. QSize sizeHint(const QStyleOptionViewItem & option, const QModelIndex & index) const;
  10. };
To copy to clipboard, switch view to plain text mode 

Qt Code:
  1. ItemImageDelegate::ItemImageDelegate(QObject *parent = 0) : QItemDelegate(parent) {}
  2.  
  3.  
  4. void ItemImageDelegate::paint(QPainter * painter, const QStyleOptionViewItem & option, const QModelIndex & index) const
  5. {
  6. qDebug()<<"Paint called";
  7. }
  8.  
  9. QSize ItemImageDelegate::sizeHint(const QStyleOptionViewItem & option, const QModelIndex & index) const
  10. {
  11. qDebug()<<"Size Hint called";
  12. }
To copy to clipboard, switch view to plain text mode 

Qt Code:
  1. // Main class
  2. // setting the model ...
  3. QTableView* view = new QTableView();
  4. view->setModel(model);
  5. ItemImageDelegate delegate(this);
  6. view->setItemDelegate(&delegate);
  7. view->resizeColumnsToContents();
  8.  
  9. view->show();
To copy to clipboard, switch view to plain text mode 

It seems so wierd to me, am for sure missing something, but I can't figure it out
Please help

Happy coding for all !!