I have a QTableView which is created on the heap in the main window.
Need to selectively color rows, so a db query gets a list of rows to be colored.
From that, I get an index list of the rows. Checked the index list and the indexes are all valid. Created a delegate to use painter( just a stub yet).
The problem comes in trying to assign the delegate to the selected rows.
Here is the offending line of code:
Qt Code:
  1. view-->QAbstractItemView::setItemDelegateForRow(rowList[i], new SentDelegate);
To copy to clipboard, switch view to plain text mode 
Gives compile error complaining it can't call the function without an object.
Qt Code:
  1. #ifndef SENTDELEGATE_H
  2. #define SENTDELEGATE_H
  3.  
  4. #include <QObject>
  5. #include <QItemDelegate>
  6. #include <QModelIndex>
  7.  
  8. class SentDelegate : public QItemDelegate
  9. {
  10. Q_OBJECT
  11. public:
  12. explicit SentDelegate(QObject *parent = 0);
  13.  
  14. signals:
  15.  
  16. public slots:
  17.  
  18. };
  19.  
  20. #endif // SENTDELEGATE_H
To copy to clipboard, switch view to plain text mode 
Qt Code:
  1. #include "sentdelegate.h"
  2. #include <QtGui>
  3.  
  4. SentDelegate::SentDelegate(QObject *parent) :
  5. QItemDelegate(parent)
  6. {
  7. }
To copy to clipboard, switch view to plain text mode 
And in mainwindow.h
Qt Code:
  1. #include "sentdelegate.h"
To copy to clipboard, switch view to plain text mode 
I used the same approach with a different form and delegate and it works fine.
Where am I going wrong here?