A delegate class to manage properties of ColorTableView.
Definition at line 24 of file ColorTableView.h.
#include <ColorTableView.h>
|
| | ColorTableViewDelegate (QWidget *parent=nullptr) |
| | Constructor.
|
| 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.
|
| QSize | sizeHint (const QStyleOptionViewItem &option, const QModelIndex &index) const override |
◆ ColorTableViewDelegate()
| ColorTableViewDelegate::ColorTableViewDelegate |
( |
QWidget * | parent = nullptr | ) |
|
|
inlineexplicit |
Constructor.
Definition at line 30 of file ColorTableView.h.
31 : QItemDelegate(parent)
32 {
33 }
◆ paint()
| void ColorTableViewDelegate::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.
Definition at line 17 of file ColorTableView.cpp.
20{
21 QColor val;
22 if (index.column() == 1)
23 {
24 if (index.data().canConvert(QMetaType::QColor))
25 {
26 val = index.data().value<QColor>();
27 QBrush brush(val);
28 painter->fillRect(option.rect, brush);
29 }
30 }
31 else
32 {
33 QItemDelegate::paint(painter, option, index);
34 }
35}
◆ sizeHint()
| QSize ColorTableViewDelegate::sizeHint |
( |
const QStyleOptionViewItem & | option, |
|
|
const QModelIndex & | index ) const |
|
override |
Definition at line 37 of file ColorTableView.cpp.
39{
40 QSize s = QItemDelegate::sizeHint(option, index);
41 if (s.isValid())
42 {
43 s.setHeight(static_cast<int>(0.5 * s.height()));
44 }
45 return s;
46}
The documentation for this class was generated from the following files: