PDA

View Full Version : width of a QTableWidget



magland
14th June 2007, 09:30
How can I get the width of a table widget... I don't mean width(), but the maximum possible sum of the column widths (without needing horizontal scroll bar)?

BrainB0ne
14th June 2007, 10:46
hmmm. I looked into the Qt Assistent of Qt4 and came along this function:



QSize QAbstractScrollArea::maximumViewportSize () const
//Returns the size of the viewport as if the scroll bars had no valid scrolling range.


Maybe it's what you need, i dont use Qt4 but Qt3 :)

jpn
14th June 2007, 11:02
At least I haven't found any better way than summing QTableView::columnWidth()'s up together. "Contents size" is quite commonly requested feature for all QAbstractItemView derived classes. Someone should send a suggestion to TT..

magland
14th June 2007, 11:31
Thanks. Well that's a good step, but I also want to exclude the headers (and I guess space between columns if that exists). I just want to set the column widths so as to use the maximum space... seems like a fairly common task. But perhaps there's no good way to do it right now.



hmmm. I looked into the Qt Assistent of Qt4 and came along this function:



QSize QAbstractScrollArea::maximumViewportSize () const
//Returns the size of the viewport as if the scroll bars had no valid scrolling range.


Maybe it's what you need, i dont use Qt4 but Qt3 :)

BrainB0ne
14th June 2007, 13:09
Thanks. Well that's a good step, but I also want to exclude the headers (and I guess space between columns if that exists). I just want to set the column widths so as to use the maximum space... seems like a fairly common task. But perhaps there's no good way to do it right now.

Maybe then you can subtract the header sizes from the value this function gives you back...