Results 1 to 3 of 3

Thread: qt savegeometry multiple document interface

  1. #1
    Join Date
    Dec 2009
    Posts
    22
    Thanks
    3
    Qt products
    Qt/Embedded
    Platforms
    Unix/X11

    Default qt savegeometry multiple document interface

    Hi All,
    I'm working with an MDI. The mainwindow holds several dialogs that are shown by a view button, using mGameDialog->show( ) mGameDialog->raise( );. Everything runs fine. I can work on, resize and move the dialogs. However When I use savegeometry to save my set up all that is saved is the main window size/position ect, not the dialogs. I would like it so that when I open all the dialogs are shown in the position they were left in. Can anyone point me in the correct direction? My save and open code are as below.
    Qt Code:
    1. void MainWindow::GUI_savesettings( void )
    2. {
    3.  
    4. appSettings->setValue("state/mainWindowState", saveState( ) );
    5. appSettings->setValue("geometry/mainWindowGeometry",saveGeometry( ) );
    6.  
    7. }
    8.  
    9.  
    10. void MainWindow::GUI_loadsettings( void )
    11. {
    12. QByteArray stateData = appSettings->value("state/mainWindowState").toByteArray();
    13. QByteArray geometryData = appSettings->value("geometry/mainWindowGeometry").toByteArray();
    14.  
    15.  
    16. restoreState( stateData );
    17. restoreGeometry( geometryData );
    18.  
    19. }
    To copy to clipboard, switch view to plain text mode 

    Thanks All.

  2. #2
    Join Date
    Jan 2006
    Location
    Graz, Austria
    Posts
    8,416
    Thanks
    37
    Thanked 1,544 Times in 1,494 Posts
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: qt savegeometry multiple document interface

    Just save the geometry of each dialog as well. Probably also whether a dialog is currently shown or not.

    Cheers,
    _

  3. #3
    Join Date
    Dec 2009
    Posts
    22
    Thanks
    3
    Qt products
    Qt/Embedded
    Platforms
    Unix/X11

    Default Re: qt savegeometry multiple document interface

    Thanks, the issue is I don't know how to do that? For example if I have a dialog set in my mainwindow.h as
    Qt Code:
    1. private:
    2. Ui::MainWindow *ui;
    3.  
    4. QSettings *appSettings;
    5.  
    6. /*windows that can be drawn permently*/
    7.  
    8. GameviewDialog *mGameViewDialog;
    To copy to clipboard, switch view to plain text mode 

    how would I tell it to save mGameViewDialog? How would I ajust the below to point at that dialog?
    Qt Code:
    1. appSettings->setValue("state/mainWindowState", saveState( ) );
    2. appSettings->setValue("geometry/mainWindowGeometry",saveGeometry( ) );
    To copy to clipboard, switch view to plain text mode 
    I can't find this documented anywhere or any tutorials that tell you how to do it.
    Thanks

    should add I've tried
    Qt Code:
    1. appSettings->setValue("geometry/ViewGeometry",GameViewDialog->saveGeometry( ) );
    To copy to clipboard, switch view to plain text mode 
    then called to restore, however I get a segmentation fault
    Qt Code:
    1. mGameViewDialog->restoreGeometry( geometryData );
    To copy to clipboard, switch view to plain text mode 


    Added after 59 minutes:


    Thankyou I've solved it. I was calling the loadgui function from my mainwindow constructor. However I was doing so before setting up the dialogs. eg

    Qt Code:
    1. /*lets restore*/
    2. GUI_loadsettings( );
    3. mGameDialog = new GameDialog( this );
    To copy to clipboard, switch view to plain text mode 

    rather than
    Qt Code:
    1. mGameDialog = new GameDialog( this );
    2. /*lets restore*/
    3. GUI_loadsettings( );
    To copy to clipboard, switch view to plain text mode 

    :s
    Last edited by knobby67; 22nd August 2014 at 18:27.

Similar Threads

  1. Replies: 1
    Last Post: 19th October 2013, 14:39
  2. Replies: 5
    Last Post: 28th May 2010, 16:28
  3. saveGeometry in X11
    By arjunasd in forum Qt Programming
    Replies: 16
    Last Post: 7th August 2007, 23:56
  4. multiple page linear interface
    By ahkv9 in forum Qt Programming
    Replies: 3
    Last Post: 17th April 2007, 19:44

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.