PDA

View Full Version : Qt 3.3 QGridLayout



ToddAtWSU
15th February 2007, 16:53
I have a QGridLayout that holds multiple subclassed QGLWidgets. Occasionally I need to change the QGLWidgets held inside the QGridLayout. Whenever I need to do this I have a loop that removes the widgets and then I go about creating the widgets. The QGLWidgets are stored inside a QValueList. When I open the window containing the QGridLayout for the first time, the QGLWidgets display correctly. But when I try to switch data sets, the QGLWidgets do not display. The first displaying of the data and the displaying of the subsequent data is all using the same code so I am thinking my problems are coming when I try to remove the old QGLWidgets from the layout before creating and adding the new QGLWidgets. Here is what my removal code looks like.


for( int i = 0 ; i < mpPlots.size( ) ; i++ )
{
mpPlotsLayout->remove( *(mpPlots.at( i ) ) );
delete( *( mpPlots.at( i ) ) );
}
mpPlots.clear( );

mpPlots is a QValueList of my QGLWidgets and mpPlotsLayout is my QGridLayout. When I try to load the new data the old data does disappear but the new data does not appear. If I try to redisplay the original data it does not display anymore. If you need more information please let me know what it is you need. But since the code used to display data initially is the same as to display data later I am guessing that code is working but the code to remove the widgets from the layout is not behaving as I would expect. Thanks for your help!

ToddAtWSU
20th February 2007, 17:36
Does anybody have any ideas on what to do with this? I am still clueless on how to fix this problem. Thanks!

ToddAtWSU
23rd February 2007, 18:40
I have tried changing


for( int i = 0 ; i < mpPlots.size( ) ; i++ )
{
mpPlotsLayout->remove( *(mpPlots.at( i ) ) );
delete( *( mpPlots.at( i ) ) );
}
mpPlots.clear( );

to


for( int i = 0 ; i < mpPlots.size( ) ; i++ )
{
mpPlotsLayout->remove( mpPlots[i] );
delete( mpPlots[i] );
}
mpPlots.clear( );

But this change did not change anything. I have also tried calling hide on the QGLWidget after the remove and before the delete and this didn't help anything. I have also tried just the hide( ) call without the remove( ) call and this didn't help. I have done this in Qt 4 with a call to removeWidget( ) followed by a delete( ) call but remove doesn't seem to work. Is there something I need to do with the QGLWidget's parent? Thanks again for any help you have...this is very annoying. :confused: