虽然楼主肯定用不到了。不过还是补充一下吧,毕竟不太好搜。
下面分别对单列设置了Resize的模式。对应的意义查看qt帮助文档。
注意:StretchLastSection 为true时,对最后一列的设置会失效。setSectionResizeMode也还有一个重载函数可以对所有列设置。
m_guiTreeWidget->header()->setStretchLastSection(false);
m_guiTreeWidget->header()->setSectionResizeMode(0, QHeaderView::ResizeToContents);
m_guiTreeWidget->header()->setSectionResizeMode(1, QHeaderView::Stretch);
m_guiTreeWidget->header()->setSectionResizeMode(2, QHeaderView::Fixed);
m_guiTreeWidget->setColumnWidth(2, 50);