树只有一列的时候(或只显示一列) header()->setSectionResizeMode(QHeadView::ResizeToContents); header()->setStretchLastSection();