Reputation: 1006
I have QTreeWidget. In which I'm adding new column dynamically on button click event using setHeaderLabels. This API add new column in TreeWidget
but column is not visible in current TreeWidget
area. It adds a scroll bar in TreeWidget
. Therefore to view newly added column user has to scroll the tree.
This my scenario but I don't want to scroll. I have used update() function even though its not showing new column. Is there any way to repaint the widget.
Thank you !
Upvotes: 1
Views: 851
Reputation: 1343
Call
treeWidget->header()->setStretchLastSection(false);
at the initialization and
treeWidget->resizeColumnToContent(column);
each time your adding a column.
Upvotes: 2
Reputation: 1125
Looks like
resizeColumnToContents(int col)
will help you. (You should call it every time after adding new column)
Btw, don't forget to call
header()->setStretchLastSection(false)
on initialization of TreeView
Upvotes: 0