I'm using a Table View.
I'd like to remove the cell padding (or margin) so I can squeeze more cells in less space. How can this be achieved?
The cells size is set to 32 pixels on QT designer, if I set it smaller, the cells contents don't show and an ellipsis appears. (...)
views:
19answers:
1
+1
A:
Recommend you to use this code:
QTableView *tableView = new QTableView(this);
tableView->setModel(model_);
QHeaderView *verticalHeader = tableView->verticalHeader();
verticalHeader->setDefaultSectionSize(verticalHeader->fontMetrics().height()+2);
// or ...
QHeaderView *horizontalHeader = tableView->horizontalHeader();
horizontalHeader->setStretchLastSection(false);
horizontalHeader->resizeSection(/* your personal height */);
PS: Also I have noticed, that if in tableView
too much rows or columns, for example about 20K rows or more, this functions resizeSection()
may be too slow...
mosg
2010-06-26 13:49:24
Thanks! I'll try it. This table is fixed at 16 x 128 cells, so I guess it won't have speed issues.
Petruza
2010-06-27 14:06:10