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
Highlighted
Developer
Posts: 108
Registered: ‎09-21-2013
My Device: Blackberry Z10 STL100-1
My Carrier: Movistar
Accepted Solution

put text on a string

hi, i have some strings for values from a json online, but i want a string with unit text like °C and °F with if and else upon the AppSettings changed, so heres my code, but i think something is wrong with the setUnits

 

 if (AppSettings::isUsingFarenheit()){
                    setTemp(current0["temp_F"].toString());
                    setUnits["°F"].toString();
                }
                else {
                    setTemp(current0["temp_C"].toString());
                    setUnits["°C"].toString();
                }

 

the setTemp work well cause is extracting info from the json, but the setUnits doesnt work, any ideas?

Developer
Posts: 889
Registered: ‎08-31-2009
My Device: 9530, 9630, 9800, 8530, 9900, 9810, 9930, PlayBook, Dev Alpha
My Carrier: Verizon

Re: put text on a string

Are you sure that it shouldn't be the following?

 

 if (AppSettings::isUsingFarenheit()){
                    setTemp(current0["temp_F"].toString());
                    setUnits("°F");
                }
                else {
                    setTemp(current0["temp_C"].toString());
                    setUnits("°C");
                }

 I assume that setUnits is a method and needs to be called like one...


Read my thoughts on BlackBerry Development at news.ebscer.com
Developer
Posts: 108
Registered: ‎09-21-2013
My Device: Blackberry Z10 STL100-1
My Carrier: Movistar

Re: put text on a string

Yeah tnks that work, we'll sort of, seems to work fine but it include a letter A with some symbol above it, I don't know why

Something like this

A^ F

With the symbol above the A
Developer
Posts: 108
Registered: ‎09-21-2013
My Device: Blackberry Z10 STL100-1
My Carrier: Movistar

Re: put text on a string

I eliminate the degree symbol and the A doesn't appears anymore, but I need the degree
Developer
Posts: 1,523
Registered: ‎12-18-2012
My Device: Z30, Z10 LE, DevAlpha C, PlayBook

Re: put text on a string

[ Edited ]

Make sure that QML file is saved in UTF8 encoding (I think it's ISO by default).

 

UPD: File -> Properties in Momentics.

 

Default encoding can be set in Momentics Preferences -> General -> Workspace.

Simply start typing 'encoding' in search box in Preferences menu to find encoding settings easily.

 


Andrey Fidrya, @zmeyc on twitter
Developer
Posts: 108
Registered: ‎09-21-2013
My Device: Blackberry Z10 STL100-1
My Carrier: Movistar

Re: put text on a string

How do I save it that way?