PDA

View Full Version : Resizing QTableView



gkarthick5
6th July 2011, 08:09
I'm using a QTableView to show data from a table in the database. The QTableView is inside a QMdiSubWindow. I want to resize the table/subwindow to exactly fit the table content's width and height. Basically i don't want a horizontal scrollbar to appear (There are only 3 columns and the texts are small enough to fit inside the screen).

Is there any way to make this happen automatically?

If i use adjustSize() function, the width is a little more than what is required. Is it possible to fit it perfectly?

MarekR22
6th July 2011, 09:02
You can try call adjustSize twice. I suspect that during first call scroll bars are taken into account and this may lead to situation when adjusted windows size is little more then required.
Note that adjustSize is performing asynchronous calculation so second call of adjustSize have to be delayed until this calculations are completed.
You can test if my suspicion is proper by calling adjustSize when some button is pressed.

gkarthick5
7th July 2011, 07:20
calling adjustSize() again did not make it proper. I am manually calculating the size of the table and resizing to that size now.