예제 #1
0
void CItemDelegate::paint(QPainter *painter, const QStyleOptionViewItem &option, const QModelIndex &index) const
{
    QStyleOptionViewItem  viewOption(option);
    if (viewOption.state & QStyle::State_HasFocus)
    {
        viewOption.state = viewOption.state ^ QStyle::State_HasFocus;
    }

    QStyledItemDelegate::paint(painter, viewOption, index);
}
예제 #2
0
void ImageDelegate::paint(QPainter *painter, const QStyleOptionViewItem &option, const QModelIndex &index) const
{
    QPixmap pixmap(index.data().toString());
    QStyleOptionViewItem  viewOption(option);
    if (viewOption.state & QStyle::State_HasFocus)
    {
        viewOption.state = viewOption.state ^ QStyle::State_HasFocus;
    }

//    QItemDelegate::paint(painter, viewOption, index);

    QRect rect = option.rect;
    QRect pixmapRect(rect.left() + rect.width()/2 - 33,
                 rect.top() + rect.height()/2 - 33,
                 66, 66);
    painter->drawPixmap(pixmapRect, pixmap);
}
예제 #3
0
void CheckBoxDelegate::paint(QPainter *painter,
                             const QStyleOptionViewItem &option,
                             const QModelIndex &index) const
{
    QStyleOptionViewItem  viewOption(option);
    if (viewOption.state & QStyle::State_HasFocus)
    {
        viewOption.state = viewOption.state ^ QStyle::State_HasFocus;
    }

    QItemDelegate::paint(painter, viewOption, index);

    int status = -1;
    QPixmap image;
    status = checkBoxStatus.value(index);
    if(status != checkBox_normal
       && status != checkBox_select
       && status != checkBox_disabled){
        (const_cast<CheckBoxDelegate *>(this))->checkBoxStatus.insert(index, checkBox_normal);
        image = _pixmap_normal;
    }

    if(status == checkBox_normal)
        image = _pixmap_normal;
    else if(status == checkBox_select){
        image = _pixmap_select;
    }
    else if(status == checkBox_disabled)
        image = _pixmap_disabled;
    else
        return;

    painter->save();
    QRect rect = option.rect;
    QRect pixmapRect(rect.left() + rect.width()*1/4 - 8,
                 rect.top() + rect.height()/2 - 8,
                 16, 16);
    painter->drawPixmap(pixmapRect, image);
    painter->restore();
}