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
New Contributor
Posts: 9
Registered: ‎07-14-2013
My Device: Z10
My Carrier: Z10-STL-1

Qsetting with property

 

Hello ..

 

i need somehelp about Qsetting  with property

 

 

i did Qsetting and it's works but not works with property

 

like fontSize

 

attachedObjects: 
        TextStyleDefinition {
            id: tsd
            objectName: "tsd"  
            base: SystemDefaults.TextStyles.BodyText            
            fontSize: FontSize 
        }

 

i want save value & restore like fontSize

 

when i'm doing that ( CODE )

 

fontSize: _app.getValueFor(big.objectName,fontSize.Default) 

and big is button save value

 

i see this error

 

Type mismatch of value of the 'fontSize' property. Expecting FontSize enum and found QString

 how i'm using enum and what is it ? 

 

or there better than that ?! 

 

 

please help me !

 

Developer
Posts: 17,012
Registered: ‎07-29-2008
My Device: Z10 LE, Z30, Passport
My Carrier: O2 Germany

Re: Qsetting with property

an enum is a limitation of an int value (read about it online).
QSettings stores QVariant values, which could be an int value.

My guess would be that you currently store a string (QString) in the settings, try to store an int value (that is valid for FontSize).
----------------------------------------------------------
feel free to press the like button on the right side to thank the user that helped you.
please mark posts as solved if you found a solution.
@SimonHain on twitter
Retired
Posts: 81
Registered: ‎09-09-2013
My Device: BlackBerry Z10
My Carrier: Etisalat UAE

Re: Qsetting with property

fontSize is enumeration accept either enum type  like FontSize.XXSmall etc as mentioned in the below link

 

https://developer.blackberry.com/native/reference/cascades/bb__cascades__fontsize.html

 

However you can refer to the enum types using their integer value 70 , 120 etc. thus casting the string returned from getValueFor method will solve the issue. but make sure you use the correct enum type int value everytime storing to the QSetting/FontSize element.

 

fontSize: parseInt(app.getValueFor("FontSize", FontSize.Default))

 

Thanks,

Kareem.

Kareem ELSayed | Application Development Consultant | Developer Relations | BlackBerry | Twitter:@kemobyte