How to get a QTableView to fill 100% of the width?
45,858
Solution 1
Use view->horizontalHeader()->setStretchLastSection(true)
to make the last column expand to free space.
Additionally, use view->horizontalHeader()->setResizeMode(QHeaderView::Stretch)
to give columns the same width.
Solution 2
Here works using only with:
ui->tableView->horizontalHeader()->setSectionResizeMode(QHeaderView::Stretch);
I'm using Qt 5.2!
![Admin](/assets/logo_square_200-5d0d61d6853298bd2a4fe063103715b4daf2819fc21225efa21dfb93e61952ea.png)
Author by
Admin
Updated on August 26, 2020Comments
-
Admin almost 4 years
Here's a print screen of my software:
As you can see, the first
QTableVIew
headers do not take 100% of the width. In fact, there is a small vertical white space on the right of the fieldsize
.How can I get the headers to take 100% of the width of the
QTableView
?