开发者

Reduce a table view's cell padding or margin

开发者 https://www.devze.com 2023-01-04 20:30 出处:网络
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?

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, 开发者_C百科the cells contents don't show and an ellipsis appears. (...)

alt text http://img692.imageshack.us/img692/3484/tableviewpng.png


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...

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号