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();
    }
}

猜你喜欢

转载自www.cnblogs.com/tianmochou/p/9257113.html
今日推荐