How to stretch table column only once, on loading
I have custom class inherited from QTableView that shows custom model.
For example view shows three columns A, B, C, D. Each of which has own initial size, that was setup by
@ setColumnWidth() @
I need to stretch column B as more as possible when view is displayed to user. After that user should have ability to change width of any column.
If to use
@horizontalHeader()->setSectionResizeMode( 1, QHeaderView::Stretch )@
column will be stretched but after this user can't to change it width.
How to solve this problem?
When instantiating/ showing the view, run this code (after the data is loaded!):
If that does not work good, then read the section size after Streatch, set to Interactive, then set the saved size on that column.
Byt the way, when you set Stretch on a column, it will occupy as much of the space as possible, but you can still change size of other columns and that setting will affect the stretched column, too.
Another option is to use cascading section resizes.