PDA

View Full Version : How to find best size for QTableWidget?



plamkata
23rd July 2008, 20:39
Hi,

I've got the following problem. I have one table (QTableWidget) and I want to find out the best size for this table. With best size I mean this size of the widget that if it is smaller with only one pixel so the scrollbars should appear.
I tried different ways to get the size of the table but with no particular luck. In some cases the size is small and scrollbars appear, on other cases the size is too big and there is extra space in the widget which is blank.
Any ideas how to find out this best size ?

Thanks,
Plamen

ru_core
23rd July 2008, 21:02
hello,
have you tried

QSize size () const to get the size of your table (QTableWidget)?

plamkata
23rd July 2008, 21:23
Yes, I tried. But size() returns the preferred size for the widget ( I think the size which is set with sizeHint() ).
Since QTableWidget is derivate class of QScrollArea, I think that I need a function which to tell me at what size the scrollbars will appear for the first time and this size should be considered for best size.

jpn
24th July 2008, 19:07
QTableView::sizeHintForColumn()
QTableView::sizeHintForRow()
QTableView::horizontalHeader()
QTableView::verticalHeader()
QHeaderView::sectionSizeHint()