1.自适应 ui->treeWidget->header()->setSectionResizeMode(QHeaderView::Stretch);
拖动窗口,section的大小会跟着一起变化。
可以手动地改变section大小
2.手动
ui->treeWidget->header()->setSectionResizeMode(QHeaderView::Interactive);
拖动窗口,section不会随着一起变化。
可以手动改变section大小
3.
根据内容调整大小
ui->treeWidget->header()->setSectionResizeMode(QHeaderView::ResizeToContents);
无法手动调整section大小,section大小取决于内容。
4.固定大小
ui->treeWidget->header()->setSectionResizeMode(QHeaderView::Fixed);
无法手动调整section大小
改变窗口大小,section大小也不发生变化。