//第一个参数代表:第几列,第二个参数:代表要进行的操作(对内容进行调整,或者,添加拉伸达到拉长表格的效果) ui->tableWidget->horizontalHeader()->setSectionResizeMode(0,QHeaderView::ResizeToContents); ui->tableWidget->horizontalHeader()->setSectionResizeMode(1,QHeaderView::Stretch); ui->tableWidget->horizontalHeader()->setSectionResizeMode(2,QHeaderView::Stretch); ui->tableWidget->horizontalHeader()->setSectionResizeMode(3,QHeaderView::Stretch); ui->tableWidget->horizontalHeader()->setSectionResizeMode(4,QHeaderView::Stretch); ui->tableWidget->horizontalHeader()->setSectionResizeMode(5,QHeaderView::ResizeToContents);
效果:
标签:QHeaderView,QT,Stretch,QTableWidget,setSectionResizeMode,tableWidget,ui,一列,horiz From: https://www.cnblogs.com/RedWetPlace/p/17180517.html