[Qt-interest] Questions about table view and item delegates

Christian Gagneraud cgagneraud at techworks.ie
Fri Jan 22 14:13:46 CET 2010


On 01/22/2010 12:59 PM, Ross Bencina wrote:
> Christian Gagneraud wrote:
>
> Not sure about the other problems, but for this one...
>
>> Problem 2:
>> I'm using a grid layout for my widgets, when I resize the window, the
>> table widget is resized and fill up all the space, but the row and
>> column sizes don't change. I would like to have the columns width and
>> the rows height to spread all the available space.
>> I couldn't find so far a way to get this behaviour. Is it possible to
>> get this kind of behaviour, if so, can anyone point me to some example
>> code?
>
> Use QHeaderView::setResizeMode() to set each column and row to
> QHeaderView::Stretch
>
> You can access the horizontal and vertical headers using
> QTableView::horizontalHeader() and QTableView::verticalHeader()
>
> So something like:
>
> static void setAllSectionsToStretch( QHeaderView *hv )
> {
> for( int i=0; i < hv->count(); ++i )
> hv->setResizeMode( i, QHeaderView::Stretch );
> }
>
> ....
> setAllSectionsToStretch( view->horizontalHeader() );
> setAllSectionsToStretch( view->verticalHeader() );
> ...
>
> Perhaps you can even just use the overloaded version of setResizeMode(),
> not sure:
>
> view->horizontalHeader()->setResizeMode( QHeaderView::Stretch );
> view->verticalHeader()->setResizeMode( QHeaderView::Stretch );

Lovely! This one works perfectly!

Thanks Ross.
Chris

>
>
> Ross.
>
>




More information about the Qt-interest-old mailing list