在QTableWidget中添加按钮

环境:Qt 5.14

auto button = new QPushButton(QStringLiteral("按钮"), ui->tableWidget_1);
button->setFixedSize(60, 22);
auto cellWidget = new QWidget(this);
auto layout = new QHBoxLayout(cellWidget);
layout ->addWidget(button);
cellWidget->setLayout(layout);
ui->tableWidget_1->setCellWidget(rowIndex, colIndex, cellWidget);

 

posted @ 2022-08-02 21:52  腾鲲  阅读(1415)  评论(0编辑  收藏  举报