Resizing column width to fill column name and content
-
I am using QTableView with resizeColumnsToContents and horizontalHeader()->stretchLastSection() to adjust/configure size to show column contents.
But issue with this is that it doesn't take column name size into account. I would like that column name should not be cut off and if column content is too big than user can expand the column to see value What would be an easy way to accomplish this.
-
Hi,
Did you set the minimum section size to
-1
? -
I added table->horizontalHeader()->setMinimumSectionSize(-1) but column names are still cut off.
I am doing below 3 operations whenever I run new query on underlying QSqlQueryModel using setQuery.table->horizontalHeader()->setMinimumSectionSize(-1);
table->horizontalHeader()->stretchLastSection();
table->resizeColumnsToContents();Is there something wrong with ordering or am I missing something else because it seems table is also not occupying full space even when I have used stretchLastSection
-
I found the issue at my end. I missed that I was changing column names after call to resizeColumnsToContents. I have now moved resizeColumnsToContents and stretchLastSection call after changing column names and it worked without setMinimumSectionSize. Thank you for your help
-