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


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM