View Single Post
Markkyboy's Avatar
Posts: 433 | Thanked: 727 times | Joined on Oct 2012 @ Costa Blanca, Espaņa
#3
Originally Posted by coderus View Post
you can try to learn qml basics.

if () else if () ...
I have already mentioned in the last paragraph of my original question, that I have already tried using if/else and it does work....until I hit minus or single figures.

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:
            
    Rectangle {
        id: colorTemperature
        width: 100; height: 140
        radius: 12
        anchors.centerIn: temperatureHighLabel
        color: {
            if      (temperatureHighLabel.text >= "38" )  "#b20012" // dark red
            else if (temperatureHighLabel.text >= "32" )  "#bd0014" // red
            else if (temperatureHighLabel.text >= "27" )  "#ec0019" // scarlet
            else if (temperatureHighLabel.text >= "21" )  "#ec9649" // orange
            else if (temperatureHighLabel.text >= "16" )  "#f7c200" // yellow
            else if (temperatureHighLabel.text >= "10" )  "#9ad346" // rich green
            else if (temperatureHighLabel.text >= "4"  )  "#47b04b" // green
            else if (temperatureHighLabel.text <= "-1" )  "#4293ff" // sky blue
            else if (temperatureHighLabel.text <= "-7" )  "#3c00ff" // blue
            else if (temperatureHighLabel.text <= "-12")  "#6a28a3" // purple
            else if (temperatureHighLabel.text <= "-18")  "#8d009a" // pinky purple
            else if (temperatureHighLabel.text <= "-23")  "#bd009a" // magenta
       }
}
the use of if/else above is the same as I used in windDirection, I wrongly assumed it would work, but it does work until minus or single figures occur. I don't know how to solve it, so I ask for help.

Did you never ask for help while learning your trade?
__________________
..oO(Don't just sit there standing around, pick up a shovel and sweep up!)Oo..