Results 1 to 2 of 2

Thread: saveState with multiple windows

  1. #1
    Join Date
    Jun 2008
    Posts
    88
    Thanks
    4
    Thanked 4 Times in 3 Posts
    Qt products
    Qt3 Qt4
    Platforms
    MacOS X Unix/X11
    Wiki edits
    1

    Default saveState with multiple windows

    I have an application based off of http://wiki.qtcentre.org/index.php?t...ed_Main_Window which when closed saves the window state to a file keeping track of the dock widget positions and sizes using QMainWindow.saveState(). So the next time I open the application it comes up in the same configuration it was left in.

    That works well for the example of the wiki but now I'd like to be able to tear off one of the dockwidgets into a separate dialog (not just a floating dock widget but actually in a separate QDialog/QMainWindow which may require reparenting...)

    Is there a good way to save the application state in that case?

    The only other thing I can think of is to tear the tool off into another QMainWindow and save the state of each main window into their own file and then create another file with the window positions/sizes and references to their saved state files. Any ideas?

  2. #2
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: saveState with multiple windows

    But what is the exact problem? You can implement saveState() for your own widgets and use it to store their state in the byte array just as QMainWindow::saveState() does and then dump the blob to the same file as the original state. Then it's just a matter of reading byte arrays back and deciding which is related to which object (you can do that by using QObject::objectName()) and call restoreState().
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


Similar Threads

  1. Activating multiple windows
    By lixo1 in forum Qt Programming
    Replies: 2
    Last Post: 12th May 2009, 20:54
  2. Multiple versions of Qt in Windows?
    By gfunk in forum Qt Programming
    Replies: 1
    Last Post: 27th August 2007, 19:07
  3. Multiple Windows -> Advice needed
    By vokal in forum Newbie
    Replies: 2
    Last Post: 8th January 2007, 08:40
  4. QGLWidget and multiple windows
    By ToddAtWSU in forum Qt Programming
    Replies: 1
    Last Post: 21st November 2006, 13:38

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.