Details
-
Suggestion
-
Resolution: Unresolved
-
P2: Important
-
6.7.2
-
None
-
Qt 6.7.2 on ubuntu 22.04
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
Gerrit Reviews
For Gerrit Dashboard: QTBUG-127762 | ||||||
---|---|---|---|---|---|---|
# | Subject | Branch | Project | Status | CR | V |
658346,1 | WIP: Warn about misleading id access | dev | qt/qtdeclarative | Status: NEW | -2 | -1 |