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

Pushing Qt.binding to JS variable in StackView results in the pushed item's property not reacting to changes

    XMLWordPrintable

Details

    • Bug
    • Resolution: Unresolved
    • P4: Low
    • None
    • 6.7
    • Quick: Controls 2
    • None
    • 6bf49d126 (dev), bd5fe124e (6.6), 38a7fc206 (6.5)

    Description

      This fails:

              // push([component, {binding}]) - with JS variable in binding
              var jsVariable = false
              var item7 = control.push([itemComponent, {objectName: Qt.binding(() => {
                  return jsVariable.toString() })}], StackView.Immediate)
              compare(item7.objectName, "false")
              compare(control.depth, 7)
              compare(control.currentItem, item7)
              jsVariable = true
              compare(item7.objectName, "true") // fails - still "false"
      

      This doesn't fail:

      import QtQuick
      import QtQuick.Controls
      
      ApplicationWindow {
          width: 400
          height: 400
          visible: true
      
          property bool bound
      
          Component.onCompleted: {
              var aFlag = false
              bound = Qt.binding(() => {
                  return aFlag.toString()
              })
              aFlag = true
              print(bound)
          }
      

      Using a QML property instead does work:

              property bool qmlProperty
      [...]
              // push([component, {binding}]) - with QML property in binding
              qmlProperty = false
              var item8 = control.push([itemComponent, {objectName: Qt.binding(() => {
                  return testCase.qmlProperty.toString() })}], StackView.Immediate)
              compare(item8.objectName, "false")
              compare(control.depth, 8)
              compare(control.currentItem, item8)
              qmlProperty = true
              compare(item8.objectName, "true")
      

      Attachments

        For Gerrit Dashboard: QTBUG-114959
        # Subject Branch Project Status CR V

        Activity

          People

            qt.team.quick.subscriptions Qt Quick and Widgets Team
            mitch_curtis Mitch Curtis
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

              Created:
              Updated:

              Gerrit Reviews

                There are no open Gerrit changes