Set column width for QTreeWidget

xander27 picture xander27 · Feb 4, 2013 · Viewed 9.7k times · Source

Is there any way to set column width for QTreeWidget from code? I want to chage default width of first column. I'm using PySide.

Answer

Chris picture Chris · Feb 4, 2013

QHeaderView::resizeSection() should do the trick, in C++ it would look like this:

myTreeWidget->headerView()->resizeSection(0 /*column index*/, 100 /*width*/);