Details
-
Bug
-
Resolution: Unresolved
-
Not Evaluated
-
None
-
6.5.3, 6.7.3, 6.8.0
-
None
Description
This is one of the most frustrating Qt bugs I've encountered. I spent hours trying to debug what's wrong with my code.
Here's how to reproduce it. Run the following code, and scroll. You'll notice 2 incorrect behaviors:
- The delegate properties CHANGED signal are being fired for no good reason (they haven't changed, they should not be called).
- The index of the supposed CHANGED delegates is ALWAYS 0, for all of them.
This has caused some nasty bugs on my program. I believe I have the same issue with my previous app as well, but somehow managed to work around it temporarily.
The issue is NOT present if I'm not using the "required" keyword, and instead using the non-recommend injected "model" to access the roles of the model.
This issue is present even when using AbstractListModel passed from C++ (my original situation, I just managed to reproduce it using QML ListModel as well).
import QtQuick import QtQuick.Controls Window { id: root width: 400 height: 400 visible: true ListModel { id: testModel Component.onCompleted: { for (let i = 0; i < 100; i++) { testModel.append({message: "Hello", messageRole: 1}); } for (let j = 0; j < 100; j++) { testModel.append({message: "Bye", messageRole: 2}); } } } ListView { anchors.fill: parent model: testModel delegate: Text { id: delegate color: "black" width: implicitWidth height: implicitHeight text: message required property int index required property string message required property int messageRole onMessageChanged: { console.log("message changed at index:", index, "messageRole:", delegate.messageRole ,"message:", message); } } } }