PDA

View Full Version : Distribute columns in QTableView



qlands
17th August 2011, 15:02
Hi,

Is there any quick way (already made procedure) to distribute the columns in a QTableView to cover the 100% of the view. I can see that there is resizeColumnsToContents() but if the number of columns does not exceed the size of the view a white space is left.

Thanks,
Carlos.

nix
17th August 2011, 15:33
try this



ui->tableView->horizontalHeader()->setResizeMode(3, QHeaderView::ResizeToContents);

ui->tableView->horizontalHeader()->setResizeMode(0, QHeaderView::Stretch);
ui->tableView->horizontalHeader()->setResizeMode(1, QHeaderView::Stretch);
ui->tableView->horizontalHeader()->setResizeMode(2, QHeaderView::Stretch);


Column 0,1 & 2 will stretch and assure a 100% width use of the available space, column 3 will be adjusted right.