View Full Version : [solved]Help!how to use QSettings save and read settings of QList<QTime>
75543255
2nd September 2009, 11:20
I want to save the QList<QTime> before quit the App add read it when the App run.
QList<QTime> timeList;
//save settings
settings.setValue("timeList",timeList);//Is this right?
//read settings
timeList=settings.value("timeList").toList();//It does work
//how can I do?
who can help me?
thank you!!
wysota
2nd September 2009, 11:26
QVariantList timeList;
timeList << QTime(...) << QTime(...);
settings.setValue("timeList", timeList);
QVariantList reading = settings.value("timeList").toList();
QList<QTime> times;
foreach(QVariant v, reading){
times << v.toTime();
}
75543255
2nd September 2009, 13:36
QVariantList timeList;
timeList << QTime(...) << QTime(...);
settings.setValue("timeList", timeList);
QVariantList reading = settings.value("timeList").toList();
QList<QTime> times;
foreach(QVariant v, reading){
times << v.toTime();
}
the code in second line can replaced by this:
//timeList << QTime(...) << QTime(...);
//QList<QTime> times;
//QVariantList timeList;
foreach(QTime t,times)timeList<<t;
My problem is solved.
Thank you very much.
Powered by vBulletin® Version 4.2.5 Copyright © 2024 vBulletin Solutions Inc. All rights reserved.