#include "mytimedelegate.h" #include #include 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); }