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

相关文章:

  • 2021-07-13
  • 2021-11-17
  • 2021-10-07
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-01-19
  • 2021-11-13
猜你喜欢
  • 2021-09-19
  • 2021-07-16
  • 2022-01-09
  • 2022-01-13
  • 2021-04-24
  • 2022-03-04
  • 2022-12-23
相关资源
相似解决方案