You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
35 lines
1.0 KiB
C++
35 lines
1.0 KiB
C++
8 years ago
|
#include "colorcmbboxitemdelegate.h"
|
||
|
|
||
|
#include <QApplication>
|
||
|
#include <QDebug>
|
||
|
#include <QPainter>
|
||
|
#include <QString>
|
||
|
|
||
|
|
||
|
ColorCmbBoxItemDelegate::ColorCmbBoxItemDelegate(QObject *parent)
|
||
|
: QAbstractItemDelegate(parent)
|
||
|
{
|
||
|
}
|
||
|
|
||
|
void ColorCmbBoxItemDelegate::paint(QPainter *painter, const QStyleOptionViewItem &option, const QModelIndex &index) const
|
||
|
{
|
||
|
QStyleOptionViewItem myOption = option;
|
||
|
//QString text = Items[index.row()].c_str();
|
||
|
//myOption.text = text;
|
||
|
QVariant value = index.data(Qt::DisplayRole);
|
||
|
|
||
|
if (value.isValid()) {
|
||
|
qDebug() << value.toString();
|
||
|
/*QString colorPath = m_iconsPath + value.toString() + "print.jpg";
|
||
|
QBrush colorBrush;
|
||
|
colorBrush.setTextureImage(QImage(colorPath).scaled(QSize(50, 50)));
|
||
|
|
||
|
painter->setBrush(colorBrush);
|
||
|
painter->drawRect(QRect(option.rect.x(), option.rect.y(),
|
||
|
option.rect.width(), option.rect.height()));*/
|
||
|
}
|
||
|
|
||
|
QApplication::style()->drawControl(QStyle::CE_ItemViewItem, &myOption, painter);
|
||
|
}
|
||
|
|