18 #include <QHeaderView>
23 this->verticalHeader()->hide();
24 this->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
25 this->resizeColumnsToContents();
26 this->resizeRowsToContents();
30 const QStyleOptionViewItem& option,
31 const QModelIndex& index)
const
34 if (index.column() == 1)
36 if (index.data().canConvert(QMetaType::QColor))
38 val = index.data().value<QColor>();
40 painter->fillRect(option.rect, brush);
45 QItemDelegate::paint(painter, option, index);
50 const QModelIndex& index)
const
52 QSize s = QItemDelegate::sizeHint(option, index);
55 s.setHeight(
static_cast<int>(0.5 * s.height()));
Definition of the ColorTableView class.
QSize sizeHint(const QStyleOptionViewItem &option, const QModelIndex &index) const override
void paint(QPainter *painter, const QStyleOptionViewItem &option, const QModelIndex &index) const override
Overwrites the paint-method to set user-defined properties instead of the default properties.
ColorTableView(QWidget *parent=nullptr)
Constructor.