void QStandardItem::setBackground ( const QBrush & brush )
void GuiDelegate::paint(QPainter *painter, const QStyleOptionViewItem &option, const QModelIndex &index) const{ if (index.column() != Gui::COLUMN_IMAGE) { QStyleOptionViewItem opt(option); opt.decorationSize = QSize(0, 0); if (option.state & QStyle::State_Selected) { QColor colIndex = index.data(Qt::BackgroundColorRole).value<QColor>(); //QBrush brush; QPalette palette; if ((colIndex.blue() + colIndex.red() + colIndex.green() + colIndex.alpha()) < 1020) { //brush.setColor(QColor(0,0,255,30)); palette.setColor(QPalette::Normal, QPalette::Highlight, QColor(0,0,255,30)); } else { //brush.setColor(QColor(0,0,255,255)); palette.setColor(QPalette::Normal, QPalette::Highlight, QColor(0,0,255,255)); } painter->fillRect(option.rect, colIndex); painter->fillRect(option.rect, palette.highlight()/*brush*/); } QItemDelegate::paint(painter, opt, index); } else { if (!index.data(Qt::DecorationRole).isNull()) { QImage pic = index.data(Qt::DecorationRole).value<QImage>(); painter->drawImage(option.rect, pic, pic.rect()); } else { bool wait = mod_->getWait(); if (!wait) { //if (!index.data(Qt::DisplayRole).isNull()) { QModelIndex *ind = new QModelIndex(index); mod_->setPic(ind); //} } } } QPen pen = painter->pen(); QPen newPen(Qt::black); newPen.setWidth(1); painter->setPen(newPen); painter->drawLine(option.rect.bottomLeft(), option.rect.bottomRight()); painter->drawLine(option.rect.topRight(), option.rect.bottomRight()); painter->setPen(pen); }