Results 1 to 2 of 2

Thread: QSettings and QGLWidgets

  1. #1
    Join Date
    Jan 2006
    Location
    Third rock from the sun
    Posts
    106
    Thanks
    17
    Thanked 6 Times in 6 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Talking QSettings and QGLWidgets

    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:
    Qt Code:
    1. void MainWindow::readSettings( )
    2. {
    3. QSettings settings( "MyCorp", "Test" );
    4.  
    5. if( mWindowType == DEFAULT )
    6. {
    7. settings.beginGroup( "DefaultWindow" );
    8. }
    9. else
    10. {
    11. settings.beginGroup( "SecondaryWindow" );
    12. }
    13.  
    14. resize( settings.value( "size", QSize( 1000, 800 )).toSize() );
    15. move( settings.value( "position", QPoint( 200, 200 )).toPoint( ) );
    16. settings.endGroup( );
    17. }
    18.  
    19. void MainWindow::writeSettings( )
    20. {
    21. QSettings settings( "MyCorp", "Test" );
    22.  
    23. if( mWindowType == DEFAULT )
    24. {
    25. settings.beginGroup( "DefaultWindow" );
    26. }
    27. else
    28. {
    29. settings.beginGroup( "SecondaryWindow" );
    30. }
    31.  
    32. settings.setValue( "size", size() );
    33. settings.setValue( "pos", pos( ) );
    34. settings.endGroup( );
    35. }
    To copy to clipboard, switch view to plain text mode 
    The call to readSettings( ) is done in the constructor and the writeSettings( ) is done in the closeEvent. Thanks in advance!

  2. #2
    Join Date
    Feb 2006
    Location
    Oslo, Norway
    Posts
    6,264
    Thanks
    36
    Thanked 1,519 Times in 1,389 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows Symbian S60 Maemo/MeeGo

    Default Re: QSettings and QGLWidgets

    Are you able to reproduce the problem with a minimal compilable example?
    J-P Nurmi

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.