Uploaded image for project: 'Qt'
  1. Qt
  2. QTBUG-56125

Component pushed on StackView does not bind properties

    XMLWordPrintable

Details

    • Bug
    • Resolution: Out of scope
    • Not Evaluated
    • 5.7.1
    • 5.6.0
    • Quick: Controls 1
    • None
    • Mac, Qt 5.6

    Description

      The example below illustrates my problem.
      I create a small `Rectangle` at the top left and clicking on it toggles the color between red and green.

      Next, I create a `StackView` and I push a `Rectangle` to the `StackView` and bind the color of this second Rectangle to the color of the top-left rectangle

      Expected behavior would be that, clicking on the top-left `Rectangle` would change the color of both `Rectangle` objects. Unfortunately, this is not the case.

      Note that things work fine when pushing `stackRect2` to the stack (see line in comment)

      Is this expected behavior or a bug?

          import QtQuick 2.0
          import QtQuick.Window 2.2
          import QtQuick.Controls 1.4
          
          Window {
              id: mainWindow
              visible: true
              width: 1280
              height: 720
          
              Rectangle {
                  id: rect
                  width: 100
                  height: 100
                  focus: true
          
                  color: toggle? "red":"green"
                  property var toggle:false;
                  MouseArea {
                      anchors.fill: parent
                      onClicked: rect.toggle = !rect.toggle
                  }
              }
          
              StackView {
                  id: stack
                  width: 100
                  height:100
                  anchors.left: rect.right
                  anchors.leftMargin: 10
          
                  Component.onCompleted: {
                      stack.push ({item:stackRect, properties: {color:rect.color}})
                      //stack.push ({item:stackRect2})
                  }
              }
          
              Component {
                  id:stackRect
                  Rectangle {}
              }
              Component {
                  id:stackRect2
                  Rectangle {color:rect.color}
              }
          }
      
      

      Attachments

        No reviews matched the request. Check your Options in the drop-down menu of this sections header.

        Activity

          People

            laknoll Lars Knoll
            vdaele vdaele
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Gerrit Reviews

                There are no open Gerrit changes