qt tableview里面添加控件

在QStyledItemDelegate的paint方法里面

void MyItemModelDeletage::paint(QPainter *painter, const QStyleOptionViewItem &option, const QModelIndex &index) const
{
    HtItemModelDeletage::paint(painter,option,index);
    if(index.column() == 0)

    {
                painter->save();
                QPushButton *button = new QPushButton(this);
                button->resize(option.rect.size() );
                painter->translate(option.rect.topLeft());                
                button->render(painter, QPoint(), QRegion(), QWidget::DrawChildren );
                painter->restore();
    }
}
posted @ 2018-07-03 10:08  beautifulday  阅读(3836)  评论(0编辑  收藏  举报