While this might seem to duplicate behaviour I believe having this code in a delegate is a better solution. - the logic in BaseTableModel is view logic not model logic - letting the custom delegate determine the formatting is much more efficient then letting the default delegate do many virtual calls to detemine how the model wants it formatted.
18 lines
469 B
C++
18 lines
469 B
C++
#ifndef PGLABITEMDELEGATE_H
|
|
#define PGLABITEMDELEGATE_H
|
|
|
|
#include <QStyledItemDelegate>
|
|
|
|
class PgLabItemDelegate : public QStyledItemDelegate
|
|
{
|
|
public:
|
|
PgLabItemDelegate(QObject *parent = nullptr);
|
|
|
|
virtual void paint(QPainter *painter, const QStyleOptionViewItem &option, const QModelIndex &index) const override;
|
|
|
|
protected:
|
|
virtual void initStyleOption(QStyleOptionViewItem *option, const QModelIndex &index) const override;
|
|
|
|
};
|
|
|
|
#endif // PGLABITEMDELEGATE_H
|