View Full Version : Minimise row height in Tables
pospiech
3rd May 2009, 15:34
I am using both QTableWidget and QTableView Classes.
Now these widgets take much more space in height than a listview with the same data. Now I want to minimize the row height for all rows to the minimum possible value.
I have seen the function
void setRowHeight ( int row, int height ) but that has to be applied to all rows and is not available in QTableWidget.
Any hints appreciated.
Matthias
Use void QTableView::resizeRowToContents( int row ) instead (by the way: setRowHeight() is inherited by QTableWidget ;)).
Yesterday I had the same problem. I didn't know what height to give setRowHeight() so I simply tried resizeRowToContents(). I hoped to get a minimized row height and a width that would show all the text in my table.
The latter didn't happen, but the row height was minimized *juhu*.
aamer4yu
3rd May 2009, 16:44
To resize row in a table, try :
table->verticalHeader ()->setDefaultSectionSize(height);
Refer : QTableView::verticalHeader and QHeaderView::setDefaultSectionSize
In addition with QHeaderView::minimumSectionSize() this might do the job.
aamer4yu
3rd May 2009, 17:39
Setting minimum will not reduce the row height. It will just tell that height shud be ATLEAST minimum...
I thought of using the return value of minimumSectionSize() as argument of setDefaultSectionSize().
pospiech
3rd May 2009, 17:59
Using
tableViewPowerDegree->verticalHeader()->setDefaultSectionSize(tableViewPowerDegree->verticalHeader()->minimumSectionSize());
works perfect in a QTableView Class
A QTreeWidget can have multiple rows and columns and has a smaller default row-to-row distance than a QTableWidget.
Powered by vBulletin® Version 4.2.5 Copyright © 2024 vBulletin Solutions Inc. All rights reserved.