Results 1 to 2 of 2

Thread: QSettings Assignment

  1. #1
    Join Date
    Apr 2010
    Posts
    769
    Thanks
    1
    Thanked 94 Times in 86 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11

    Default QSettings Assignment

    I'll be using a QSettings object to store and save user preferences in an upcoming project. One request is to enable the user to simply "Apply" their preferences changes, rather than save them; such settings would be used until the end of the current session, or until the user changed them again, but settings that were "Save"d during a prior session would remain in effect in the future.

    My first thought was to maintain two setting objects, one corresponding to the setting currently in use and possibly modified through "Apply," and another corresponding to the "Save"d settings. The simplest way to make this work would be to assign one QSettings object to the other as needed, so that only the persistent copy would be saved, but the other, possibly transient copy would be used by the program when when applying settings.

    That won't work, however, because assignment and copy construction of this object is disallowed, and there is no 'clone' method.

    Another approach would be to write a second backing store, but this seems needlessly complex.

    Any thoughts on how best to accomplish this task?

  2. #2
    Join Date
    May 2009
    Location
    USA
    Posts
    300
    Thanks
    82
    Thanked 11 Times in 11 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: QSettings Assignment

    One way would be to make two tables in SQLite - one for session and one for permanent.
    It's easy code to store whatever settings you want - window positions, sizes, colors, font, etc.
    Then just delete from the session table when the users closes the application.

Similar Threads

  1. QString assignment
    By valgaba in forum Qt Programming
    Replies: 4
    Last Post: 25th April 2010, 17:31
  2. QVector assignment question
    By hvw59601 in forum Qt Programming
    Replies: 1
    Last Post: 14th November 2007, 20:34
  3. Do assignment operators in Qt4 return deep or shallow copy?
    By high_flyer in forum Qt Programming
    Replies: 5
    Last Post: 25th September 2006, 09:01
  4. copying and assignment constructors
    By TheKedge in forum General Programming
    Replies: 3
    Last Post: 17th August 2006, 15:09
  5. QMap <int, QGuardedPtr<Employee> > Crashes on Assignment ???
    By sunil.thaha in forum Qt Programming
    Replies: 2
    Last Post: 16th March 2006, 07:09

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.