Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

QTreeView middle column fill width space instead of last column

How can do this:

middle column fill space

I already tried this way:

view->header()->setResizeMode(INDEX_COLUMN_SKU, QHeaderView::Interactive);
view->header()->setResizeMode(INDEX_COLUMN_NAME, QHeaderView::Stretch);
view->header()->setResizeMode(INDEX_COLUMN_QUANTITY, QHeaderView::Interactive);
view->header()->setResizeMode(INDEX_COLUMN_PRICE, QHeaderView::Interactive);

but does not work.

like image 837
Sebtm Avatar asked Jan 24 '12 11:01

Sebtm


1 Answers

Did you remember to view->header()->setStretchLastSection(false)?

Here are some examples:

Default Behavior

Default behavior

Just disabling stretch on the last column:

treeView->header()->setStretchLastSection(false); 

Stretch_Disabled

Both attributes combined:

treeView->header()->setStretchLastSection(false); treeView->header()->setResizeMode(1, QHeaderView::Stretch);    

From QT5 onwards:

treeView->header()->setStretchLastSection(false); treeView->header()->setSectionResizeMode(1, QHeaderView::Stretch); //! qt5 api change  

Stretch_Disabled+Resizable_Second_Col

like image 100
synthesizerpatel Avatar answered Sep 28 '22 17:09

synthesizerpatel