Welcome!

Welcome to the official BlackBerry Support Community Forums.

This is your resource to discuss support topics with your peers, and learn from each other.

inside custom component

Native Development

Reply
Developer
Posts: 232
Registered: ‎01-30-2011
My Device: Dev Alpha C, Z10 LE
My Carrier: P4
Accepted Solution

Saving QTime in QSettings - problem

I try to save some settings. The code below shows correct alert box with correct zoom and updInter values.

QSettings settings("ASDF", "QAZWSX");

QTime pickerTime=root->property("pickerTime").toTime();

settings.beginGroup("AppSettings");
	settings.setValue("zoom", root->property("zoom"));
	settings.setValue("updInter", pickerTime);
	alert(settings.value("updInter", "E4").toTime().toString());
settings.endGroup();

 

 

But code below (run at start of app) shows correct alert box with correct zoom and incorrect (00:00:00) updInter values...

QSettings settings("ASDF", "QAZWSX");

settings.beginGroup("AppSettings");
	alert(settings.value("zoom", "E3").toString()+" "+settings.value("updInter", "E4").toTime().toString());
settings.endGroup();

 

Thank You in advance for help :smileywink:

All time online :smileyvery-happy:
Contributor
Posts: 40
Registered: ‎05-14-2013
My Device: Z10
My Carrier: none

Re: Saving QTime in QSettings - problem

[ Edited ]

Try to push the time as-is, no need to do a toString()

 

See also QVariant::value<QTime>() to get it back.

Developer
Posts: 232
Registered: ‎01-30-2011
My Device: Dev Alpha C, Z10 LE
My Carrier: P4

Re: Saving QTime in QSettings - problem

toString() deens my alert function...

 


tzander wrote:

See also QVariant::value<QTime>() to get it back.


How can I it do?

All time online :smileyvery-happy:
Contributor
Posts: 40
Registered: ‎05-14-2013
My Device: Z10
My Carrier: none

Re: Saving QTime in QSettings - problem

Sorry, I thought with my answer the rest usage would follow;

 

Maybe the missing point is that you can put a QTime in QVariant with no extra work.

 

So you'd write;

 

QVariant var;

var.setValue<QTime>(myTime);

settings.setValue("bla", var);

 

and later;

 

QVariant var = settings.value("bla");

QTime myTime = var.value<QTime>();

 

Developer
Posts: 232
Registered: ‎01-30-2011
My Device: Dev Alpha C, Z10 LE
My Carrier: P4

Re: Saving QTime in QSettings - problem

Thank you, @tzander, but saving QTime wasn't error - the real error was this, that in some moments (probably onExit), application saves QTime == "00:00:00".

 

So I create simple ease condition:

if(root->property("pickerTime").toString().remove(0,11).compare("00:00:00")!=0){
	settings.setValue("updInter", root->property("pickerTime"));
}

 where in QML file, I have

property alias pickerTime: intervalPicker.value

(...)

DateTimePicker {
       id: intervalPicker
       mode: DateTimePickerMode.Timer
       value: dateFromTime("00:00:15")
       title: qsTr("Select")
}

 

I think, that it's very funny, that DateTimePicker sometimes change time value :smileyvery-happy:

 

All time online :smileyvery-happy: