-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathcellborderdelegate.h
More file actions
32 lines (27 loc) · 817 Bytes
/
cellborderdelegate.h
File metadata and controls
32 lines (27 loc) · 817 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
#ifndef CELLBORDERDELEGATE_H
#define CELLBORDERDELEGATE_H
#include <QModelIndex>
#include <QPainter>
#include <QStyledItemDelegate>
class CellBorderDelegate : public QStyledItemDelegate
{
Q_OBJECT
public:
explicit CellBorderDelegate(QObject *parent = 0) : QStyledItemDelegate(parent)
{ }
void paint(QPainter *painter,
const QStyleOptionViewItem &option,
const QModelIndex &index) const
{
QStyledItemDelegate::paint(painter, option, index);
bool selected = index.data(Qt::UserRole).toBool();
if (selected) {
QPen pen = painter->pen();
pen.setColor(Qt::red);
pen.setWidth(3);
painter->setPen(pen);
painter->drawRect(option.rect);
}
}
};
#endif // CELLBORDERDELEGATE_H