Columns auto-resize to the size of QTableView

This code equally stretches each column so that they fit the table’s width.

table->horizontalHeader()->setSectionResizeMode(QHeaderView::Stretch);

Docs:

  • QHeaderView::setSectionResizeMode
  • See resize modes here.

Leave a Comment