PDA

View Full Version : Resizing columns of a table?



qtzcute
16th August 2009, 05:21
Hi all,

I am using QTableView for generating a table for my data. Problem is that i want the table to capture all the horizental space available in the TableView but i can't make it yet.

I used following LOC but invain...

tableView_processInfo->horizontalHeader() -> resizeSections(QHeaderView::Stretch);

For just testing i wrote:

tableView_processInfo->setColumnWidth(2,500)
but it did not result into anything either.

where tableView_processInfo is my table's name. Also, have a look of the attached picture to see what's wrong.

Thanks a lot

qtzcute
16th August 2009, 07:57
Problem Solved!

Following LOC did what i wanted


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

One more problem :)

I wanted that the columns may take the available space as well as the user may be able to change the width of the columns 'interactively' so i used following LOCs. The interactively changing widths worked but the first problem is still there i.e. columns are not taking the available space even though i have stretched the last section...Any idea?



tableView_filesInfo->horizontalHeader()->setResizeMode(QHeaderView::Interactive);
tableView_filesInfo->horizontalHeader()->stretchLastSection();


Thanks again..

axeljaeger
16th August 2009, 09:48
stretchLastSection() is a getter to the property stretchLastSection, it is not a slot that does anything. Try setStretchLastSection(true)

qtzcute
16th August 2009, 10:07
oh i missed that. Thanks