Details
-
Suggestion
-
Resolution: Done
-
P2: Important
-
4.7.0
-
None
-
Mac OS 10.6.3, Win7-32
Description
Please consider the following example. I can only work with the property, after reassigning it to a local variable aa:
import Qt 4.7 Rectangle { id: rect width: 640 height: 480 property variant a: [] Component.onCompleted: { console.log("a===rect.a:", a===rect.a); console.log("isArray:", Array.isArray(a)); for(var i=0; i< 4; i++) { a.push( i ); console.log(i, "a > ", JSON.stringify(a), a.length); } var aa = rect.a; // reassigning fixed the problem for(var i=0; i< 4; i++) { aa.push( i ); console.log(i, "aa > ", JSON.stringify(aa), aa.length); } } } /* Outputs the following: a===rect.a: false isArray: true 0 a > [] 0 1 a > [] 0 2 a > [] 0 3 a > [] 0 0 aa > [0] 1 1 aa > [0,1] 2 2 aa > [0,1,2] 3 3 aa > [0,1,2,3] 4 */
Attachments
Issue Links
- relates to
-
QTBUG-12117 Add support for JS arrays in ListModel
- Open
- replaces
-
QTBUG-15212 variant property wrapper behaves like an array, but fails for splice or delete
- Closed