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.

Qt Code:
  1. for( int i = 0 ; i < mpPlots.size( ) ; i++ )
  2. {
  3. mpPlotsLayout->remove( *(mpPlots.at( i ) ) );
  4. delete( *( mpPlots.at( i ) ) );
  5. }
  6. mpPlots.clear( );
To copy to clipboard, switch view to plain text mode 

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!