QT QTableWidget 设置每一列的宽度(大概可以实现)
//第一个参数代表:第几列,第二个参数:代表要进行的操作(对内容进行调整,或者,添加拉伸达到拉长表格的效果) 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);
效果: