PDA

View Full Version : show and resize sequence



Windsoarer
12th May 2012, 11:36
Hi all,

This is a question about the sequence in which child widgets are shown and resized when a parent dialog is displayed.
What I'd liked to do :
1. Just before the QDialog is shown, get the size of a QTableView inside the QDialog
2. Adjust the column widths
3. Show the QDialog

Unfortunately, if I try to resize the columns either in an override of the QDialog's showEvent or resizeEvent, the QDialog has indeed been resized, but not yet the child widgets

Unless it's possible to get the resized QTableView before the dialog is shown, I'll have to subclass QTableView and override it's resizeEvent, which is bit cumbersome.

Is there another (and proper) way to do this ?

Thanks for any insight.

Spitfire
14th May 2012, 17:29
Install event filter on the view and resize the columns there.



QTableView* v = new QTableView( this );
v->installEventFilter( this );

bool eventFilter( QObject* o, QEvent* e )
{
if( o == v && e->type() == QEvent::Resize )
{
// get size from event, resize columns here
}

return QDialog::eventFilter( o, e );
}

Windsoarer
20th May 2012, 21:36
Works nicely
Thanks