12345678910111213141516171819202122232425 |
- #include "mytimedelegate.h"
- #include <QPainter>
- #include <QMouseEvent>
- MyTimeDelegate::MyTimeDelegate(QObject* parent) :
- QStyledItemDelegate(parent)
- {
- }
- void MyTimeDelegate::paint(QPainter *painter, const QStyleOptionViewItem &option, const QModelIndex &index) const
- {
- if (nullptr == painter || !index.isValid()) {
- return;
- }
- QString data = index.data().toString();
- if (data.isEmpty()) {
- if ((option.state & QStyle::State_MouseOver) ||
- (option.state & QStyle::State_Selected)) {
- painter->fillRect(option.rect, c_bkColor);
- return;
- }
- }
- QStyledItemDelegate::paint(painter, option, index);
- }
|