I've got a simple question.
I have QTableView which is attached to custom model and custom delegate.
The tableview shows me 3 rows. But the columns don't fill up the entire width of the tableview.
How can i make it so that 1 particular column sizes so that all columns will fill the width of the table view.
I looked in the documentation but I can't find it. I think i missed it.
Look this : http://doc.qt.nokia.com/stable/qtableview.html
[quote author="qtrahul" date="1293382585"]Look this : http://doc.qt.nokia.com/stable/qtableview.html[/quote]
Please put the link in the format use "link":http://doc.qt.nokia.com/stable/qtableview.html icon located above your "Post Reply" box
Alternatively you can call
It sets up a different behaviour in than resizeMode. See QHeaderViews docs on "strechLastSection property":http://doc.qt.nokia.com/stable/qheaderview.html#stretchLastSection-prop for a detailed description.
Thank you all,
But setResizeMode(QHeaderView::Stretch) will stretch the columns evenly in the tablefield & setStretchLastSection(true) will do it only for the last column.
In my case I want the middle column to stretch only. But when a user adds a column to the tableview to see more detail I still want to stretch that same column (the one that was the middle column).
After some digging I found the sizeHint method in the QStyledItemDelegate and I am still figuring out how to use it.
Also promising is QTableView::resizeColumnToContents ( int column ). Somehow I have to tie (signal & slot) the slot to the delegate or model to resize the right column every time.
This cannot be achieved out of the box. The sizeHint approach might not work as expected, because it's only a hint, not a constraint.
You could could create your own QHeaderView subclass and add the functionality there. You can add it to the table view with setHorizontalHeader().