Weather temperature as colour
Hi,
as the title suggests, I'm trying to associate colours to weather temperature, mostly it seems to work until I get to single figures and minus temperatures. Here is my clunky code, this code is used in `/usr/lib/qt5/qml/Sailfish/Weather/WeatherDetailsHeader.qml` Code:
slotted in @ line: 124 I've played with this extensively, originally it was in if/else format but the same problem occurred. I've tried different java operators, I've tried adding plus/minus symbols to temp figures, but still I get dark red for single and minus figures. Any ideas appreciated. The format used for laying out my code, was taken directly from harbour-nationalrail used for associating rail operator colours. Originally, the code was laid out in the same way as my windDirection patch, that being inthe style of 'if/else' statements, but that yielded the same problem as does the above. |
Re: Weather temperature as colour
you can try to learn qml basics.
if () else if () ... |
Re: Weather temperature as colour
Quote:
I am always learning, it is fine and right for you to say, 'learn qml basics', what do you think I am trying to do?, I am constantly reading doc.qt QML documents online, I have nearly all saved as browser favourites. I also try as much as I can to solve the problems I create before asking questions here. What is clearly obvious to you in many cases, isn't so obvious to me. Most of the examples set out by Qt, is basic stuff I have already learned, basic Text, Image, Rectangle,Color and more, many of the examples do not go into any detail and what may work on a QtCreator SDK, doesn't always work in Sailfish, as we know, org.nemomobile.configuration 1.0 replaces Settings 1.0. ...when I say "doesn't always work" actually means "I don't fully understand what I'm doing" <------from that, I take cues from stuff I know that works, like reusing the contents of my WindDirection.patch, which used 'if/else' and works correctly. Code:
Did you never ask for help while learning your trade? |
Re: Weather temperature as colour
^^^ That and trying not to confuse comparing strings with numbers.
"8" > "32" or even "32000", just like "z" > "aaaaaaaaa". |
Re: Weather temperature as colour
Quote:
|
Re: Weather temperature as colour
Quote:
Being Old Skool, I would convert temperatureHighLabel.text to a number and work with that. It would be faster anyway if you do the conversion only once and not at the background for each comparison. It would also give you a lovely opportunity to change the colour continuously rather than in discreet steps like in your example ;) |
Re: Weather temperature as colour
Quote:
I don't yet know how else to actually tackle it. My WindDirection patch uses the same method, it gets windDirection as a number and converts to a given heading as text, so I know it works.....at least in that instance. thanks, |
Re: Weather temperature as colour
Quote:
|
Re: Weather temperature as colour
Try something like:
Code:
Keep in mind: Long lists of if/else almost always are a sign that something could be better thought out. Edit: The number conversion, of course, is exactly what pichlo pointed out earlier. I just wrote it down. ;) |
Re: Weather temperature as colour
Quote:
|
All times are GMT. The time now is 03:18. |
vBulletin® Version 3.8.8