1. 程式人生 > >Qt5以上QtableWiget的自適應列寬的設定

Qt5以上QtableWiget的自適應列寬的設定

ui->tableWidget->horizontalHeader()->setSectionResizeMode(0,QHeaderView::Stretch);
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);