Results 1 to 2 of 2

Thread: Saving window set up using Qsettings

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

    Default Re: Saving window set up using Qsettings

    Hi All,
    hope you can help me out with this. I'm trying to save my window setting using the code below ( from a you tube tutorial). However whatever I try when I save the window and try to load it it's tiny. So to save I use
    Qt Code:
    1. void MainWindow::GUI_savesettings( void )
    2. {
    3.  
    4. QSettings settings("mysoft", "test");
    5. settings.beginGroup("MainWindow");
    6. settings.setValue( "position", this->geometry( ) );
    7.  
    8. settings.endGroup();
    9.  
    10.  
    11. qDebug()<<"save";
    12.  
    13.  
    14. }
    To copy to clipboard, switch view to plain text mode 


    and to load
    Qt Code:
    1. void MainWindow::GUI_loadsettings( void )
    2. {
    3. QSettings settings("mysoft", "test");
    4. settings.beginGroup("MainWindow");
    5. QRect myrect = settings.value( "position " ).toRect();
    6. setGeometry( myrect );
    7. settings.endGroup();
    8.  
    9. }
    To copy to clipboard, switch view to plain text mode 

    When I debug I can set that in my load function myrect is set to postion,sizes 0,0,0,0.

    I'm running Linux Lubuntu, could this be the cause? Or is there some error in my code? Or some mod to the way Qt handles this, I'm using 5.0.17
    Thanks in advance.


    Added after 23 minutes:


    SOLVED
    I copied the tutorial from http://contingencycoder.wordpress.co...ometry-part-2/
    This works great
    Last edited by knobby67; 21st August 2014 at 17:27.

  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: Saving window set up using Qsettings

    You are using two different keys.

    "position" for saving, "position " for reading

    Cheers,
    _

  3. The following user says thank you to anda_skoa for this useful post:

    knobby67 (21st August 2014)

Similar Threads

  1. Saving QTransform in QSettings
    By Cruz in forum Qt Programming
    Replies: 1
    Last Post: 17th November 2012, 01:18
  2. Replies: 3
    Last Post: 18th September 2012, 05:46
  3. OSX QSettings IniFormat SystemScope saving inside the bundle
    By JoZCaVaLLo in forum Qt Programming
    Replies: 1
    Last Post: 27th April 2012, 11:21
  4. Replies: 1
    Last Post: 14th January 2011, 12:57
  5. Migrate Qt3 QSettings to Qt4 QSettings
    By hvengel in forum Qt Programming
    Replies: 3
    Last Post: 22nd February 2008, 04:21

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.