Because you are calling the code too early. Qt models tell you when something changes in them and you either have to react on each of the changes of detect when the model stops signalling you that it is changing. Of course nothing guarantees that it will not change a second later but you can't solve it with resizeColumnToContents() anywayThat's why we have QHeaderView::ResizeToContents resize mode
![]()
Bookmarks