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:
view-->QAbstractItemView::setItemDelegateForRow(rowList[i], new SentDelegate);
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.
#ifndef SENTDELEGATE_H
#define SENTDELEGATE_H
#include <QObject>
#include <QItemDelegate>
#include <QModelIndex>
{
Q_OBJECT
public:
explicit SentDelegate
(QObject *parent
= 0);
signals:
public slots:
};
#endif // SENTDELEGATE_H
#ifndef SENTDELEGATE_H
#define SENTDELEGATE_H
#include <QObject>
#include <QItemDelegate>
#include <QModelIndex>
class SentDelegate : public QItemDelegate
{
Q_OBJECT
public:
explicit SentDelegate(QObject *parent = 0);
signals:
public slots:
};
#endif // SENTDELEGATE_H
To copy to clipboard, switch view to plain text mode
#include "sentdelegate.h"
#include <QtGui>
SentDelegate
::SentDelegate(QObject *parent
) :{
}
#include "sentdelegate.h"
#include <QtGui>
SentDelegate::SentDelegate(QObject *parent) :
QItemDelegate(parent)
{
}
To copy to clipboard, switch view to plain text mode
And in mainwindow.h
#include "sentdelegate.h"
#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?
Bookmarks