QTableView Column Width

I am trying to set the column width manually in a QTableView . Why is this piece of code not working?

 tabb = new QTableView; tabb->resizeColumnsToContents(); for (int col=0; col<20; col++) { tabb->setColumnWidth(col,80); } 

If I omit tabb->resizeColumnsToContents(); It still doesn't work.

+6
source share
1 answer

You must first set the model, after which you can change the ColumnWidth :

 tabb = new QTableView; tabb->setModel(someModel); for (int col=0; col<20; col++) { tabb->setColumnWidth(col,80); } 
+12
source

Source: https://habr.com/ru/post/977562/


All Articles