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

Item property value shadowed by another item's id in outer scope

    XMLWordPrintable

Details

    • Suggestion
    • Resolution: Unresolved
    • P2: Important
    • 6.9
    • 6.7.2
    • QML: Compiler
    • None
    • Qt 6.7.2 on ubuntu 22.04

    • Linux/Wayland

    Description

      An Item's property name can be 'shadowed' by the id of another Item in an outer scope. This behavior can lead to subtle and time-consuming bugs. Following is an example:

      Window {
      
        [...]
        Text {
          id: selectedFile
          [...]
        }
      
      
        FileDialog {
          id: fileDialog
          [...]
          onAccepted: {
            // Expect FileDialog selectedFile to be url of the last
            //  user-selected file; instead selectedFile contains a reference to the Text Item with 
            // id 'selectedFile'
            console.log('accepted ' + selectedFile);
          }
        }
      }

      It would be very useful if a warning of this ambiguity were given by tools such as qmllint or qtcreator.

      Attachments

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

        Activity

          People

            qtqmlteam Qt Qml Team User
            tom_asso tom_asso
            Votes:
            1 Vote for this issue
            Watchers:
            4 Start watching this issue

            Dates

              Created:
              Updated:

              Gerrit Reviews

                There are no open Gerrit changes