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

[Reg 5.15 -> 6.2] QML Binding on new object not re-evaluated

    XMLWordPrintable

Details

    • Linux/X11, macOS, Windows
    • 46842ec7c (dev), edd5fafa5 (6.6), 9445aaf96 (tqtc/lts-6.2), 988a30c46 (6.5)

    Description

      Simple qml bindings may fail to re-evaluate when they reference an object that has just been created.

      For example in the below image I have a simple qml application with two buttons. The first button either creates a Rectangle object and sets it's width to 1200 or deletes the previously created Rectangle. The second button simply prints the width of the Rectangle if it exists.

      If I spam the first button (see in the attached gif) you should see that the buttons text sometimes shows 1200 (CORRECT) but also sometimes shows 0 (INCORRECT). This appears to be totally random, sometimes it happens right away, sometimes it takes 30+ clicks but it does eventually happen.

      The binding that is not re-evaluating is simply:

      text: root.rectItem?.width ?? "Create Object" 

      I.e. display the width of rectItem if it exists.

      If I click button 2 while button 1 shows "0" it will correctly console.log the width of the rectItem as 1200.

      I have attached the full qml example for reference.

       

      Attachments

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

        Activity

          People

            ulherman Ulf Hermann
            haiku Ollie Dawes
            Votes:
            1 Vote for this issue
            Watchers:
            4 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Gerrit Reviews