Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. QML and Qt Quick
  4. Help with this simple property change
Forum Updated to NodeBB v4.3 + New Features

Help with this simple property change

Scheduled Pinned Locked Moved QML and Qt Quick
6 Posts 3 Posters 1.4k Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • Q Offline
    Q Offline
    qttester5
    wrote on last edited by
    #1

    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?

    1 Reply Last reply
    0
    • sierdzioS Offline
      sierdzioS Offline
      sierdzio
      Moderators
      wrote on last edited by
      #2

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

      (Z(:^

      1 Reply Last reply
      0
      • Q Offline
        Q Offline
        qttester5
        wrote on last edited by
        #3

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

        1 Reply Last reply
        0
        • sierdzioS Offline
          sierdzioS Offline
          sierdzio
          Moderators
          wrote on last edited by
          #4

          Cool, I actually thought it will fail :D

          (Z(:^

          1 Reply Last reply
          0
          • C Offline
            C Offline
            chrisadams
            wrote on last edited by
            #5

            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.

            1 Reply Last reply
            0
            • Q Offline
              Q Offline
              qttester5
              wrote on last edited by
              #6

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

              1 Reply Last reply
              0

              • Login

              • Login or register to search.
              • First post
                Last post
              0
              • Categories
              • Recent
              • Tags
              • Popular
              • Users
              • Groups
              • Search
              • Get Qt Extensions
              • Unsolved