PDA

View Full Version : QSettings and QGLWidgets



Rayven
30th May 2008, 20:24
I have a QMainWindow that contains two QGLWidgets in a QSplitter, two QSliders, a QLabel and two QToolbars.. The QGLWidgets are a threaded 2d plot library. This part of the application works very well. However, when I use QSettings to store the window positions and sizes, some "funky" things occur: None of the centralWidget elements appear. The menu and status bar show up and function properly, even opening sub plots in other windows. QSettings seems to be working for all other plot windows I have open, but they are all one QGLWidget per window. One last thing to mention, the main window class is used for two different kinds of plots (i.e. two windows open at once each with two plots). This also works great without the QSettings. If I take out code that sets the information into registry, the application works as expected. Put it back in...and it fails to draw. Does anyone have any ideas or hints? I am using VS.NET 2008, Windows XP and Qt4.4.

Here is the read/write settings functions:


void MainWindow::readSettings( )
{
QSettings settings( "MyCorp", "Test" );

if( mWindowType == DEFAULT )
{
settings.beginGroup( "DefaultWindow" );
}
else
{
settings.beginGroup( "SecondaryWindow" );
}

resize( settings.value( "size", QSize( 1000, 800 )).toSize() );
move( settings.value( "position", QPoint( 200, 200 )).toPoint( ) );
settings.endGroup( );
}

void MainWindow::writeSettings( )
{
QSettings settings( "MyCorp", "Test" );

if( mWindowType == DEFAULT )
{
settings.beginGroup( "DefaultWindow" );
}
else
{
settings.beginGroup( "SecondaryWindow" );
}

settings.setValue( "size", size() );
settings.setValue( "pos", pos( ) );
settings.endGroup( );
}

The call to readSettings( ) is done in the constructor and the writeSettings( ) is done in the closeEvent. Thanks in advance!

jpn
31st May 2008, 18:01
Are you able to reproduce the problem with a minimal compilable example?