PDA

View Full Version : QTableWidget resize to screen



Archa4
31st March 2011, 09:59
I use Qt Nokia SDK, i test my application on Maemo simulator.
I created a QTableWidget with 2 rows and 7 columns. I have a layout.
Earlier i tried a QCalendarWidget. When i add QCalendarWidget to my layout - no problem - it resizes to the layout. But when i add my QTableWidget to the layout it doesn't resizes. I tried several things, but all of them are fixed, and if I turn the phone - the size of the widget doesn't change, but i need it to take the whole screen like QCalendarWidget does. Can someone help me with this one?

I use QWidget as my main thing were I have a layout

QVBoxLayout *layout;

wysota
31st March 2011, 11:37
You need to add the widget to the layout properly and set size policies properly.

Archa4
31st March 2011, 12:07
Hm... I think I did a mistake there - the QTableWidget is properly aligned, But the columns are not. Can i somehow resize the columns, for them to fit the Layout?

Picture:
6178

And if i turn the phone vertically, then i cannot see all of the columns at once...

wysota
31st March 2011, 12:12
Yes, you can resize columns using the API of QHeaderView or QTableView.

Archa4
31st March 2011, 12:37
Hm... But is there a function to resize columns not to fixed size, not to contents, but to layout in which the QTableWidget is?

Added after 12 minutes:

Well i tried
table->horizontalHeader()->resizeSections(QHeaderView::Stretch);

I thought it should do the job but instead i got this:
6179

Any ideas?

Added after 8 minutes:

Well, I think i solved this one.
I should've used

table->horizontalHeader()->setResizeMode(QHeaderView::Stretch);