Results 1 to 3 of 3

Thread: [solved]Help!how to use QSettings save and read settings of QList<QTime>

  1. #1
    Join Date
    Aug 2009
    Posts
    5
    Thanks
    1
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Talking [solved]Help!how to use QSettings save and read settings of QList<QTime>

    I want to save the QList<QTime> before quit the App add read it when the App run.
    Qt Code:
    1. QList<QTime> timeList;
    2. //save settings
    3. settings.setValue("timeList",timeList);//Is this right?
    4. //read settings
    5. timeList=settings.value("timeList").toList();//It does work
    6. //how can I do?
    To copy to clipboard, switch view to plain text mode 

    who can help me?
    thank you!!
    Last edited by 75543255; 2nd September 2009 at 13:40. Reason: My problem is solved

  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: Help!how to use QSettings save and read settings of QList<QTime>

    Qt Code:
    1. QVariantList timeList;
    2. timeList << QTime(...) << QTime(...);
    3. settings.setValue("timeList", timeList);
    4.  
    5. QVariantList reading = settings.value("timeList").toList();
    6. QList<QTime> times;
    7. foreach(QVariant v, reading){
    8. times << v.toTime();
    9. }
    To copy to clipboard, switch view to plain text mode 
    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.


  3. #3
    Join Date
    Aug 2009
    Posts
    5
    Thanks
    1
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Talking Re: Help!how to use QSettings save and read settings of QList<QTime>

    Quote Originally Posted by wysota View Post
    Qt Code:
    1. QVariantList timeList;
    2. timeList << QTime(...) << QTime(...);
    3. settings.setValue("timeList", timeList);
    4.  
    5. QVariantList reading = settings.value("timeList").toList();
    6. QList<QTime> times;
    7. foreach(QVariant v, reading){
    8. times << v.toTime();
    9. }
    To copy to clipboard, switch view to plain text mode 
    the code in second line can replaced by this:
    Qt Code:
    1. //timeList << QTime(...) << QTime(...);
    2. //QList<QTime> times;
    3. //QVariantList timeList;
    4. foreach(QTime t,times)timeList<<t;
    To copy to clipboard, switch view to plain text mode 
    My problem is solved.
    Thank you very much.

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.