Help with this simple property change



  • I have this:

    @Rectangle{
    id:testrect

        property color gradcolor:"#8C8F8C"
        gradient:
            Gradient {
            GradientStop { position: 0.0; color: gradcolor }
            GradientStop { position: 0.17; color: "#6A6D6A" }
            GradientStop { position: 0.77; color: "#3F3F3F" }
            GradientStop { position: 1.0; color: "#6A6D6A" }
            }@
    

    In a child MouseArea, I want to do this:

    @ onEntered: {
    testrect.gradcolor="white"
    parent.border.color = Qt.lighter("#6A6D6A")
    @

    The border color is changing as desired, but the gradient colors are not. Is it because the gradient is not pulling from the gradcolor property in real time? What is the best way to approach this?


  • Moderators

    Hm, this seems to be a bug. Maybe adding an ID to the first GradientStop changing it's value directly would help?



  • setting the id directly on the stop did in fact work, thanks.


  • Moderators

    Cool, I actually thought it will fail :D



  • Hi,

    Does resolution of gradcolor fail, or does the binding simply not get re-evaluated when the gradcolor property changes?

    The resolution rules state that a property is in scope if it is a property of the current object, OR a property of the immediate parent object of the current object, OR a property of the root object of the current component.

    Obviously gradcolor is neither a property of the object nor the object's immediate parent, but I would have assumed that it would resolve as the property of the root object in the current component (since testrect is the top-level object in the QML document, it appears)... So I dunno, this seems strange.

    Cheers,
    Chris.



  • In the gradient stop, I should have used testrect.gradcolor. I forgot to reference where the property came from.


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.