[QObjectList] Cannot read property 'forEach' of null in javascript
-
Hi,
I got "Cannot read property 'forEach' of null" error message from javascript when I try to list of QObjectList using forEach.Do you know how to enumerate the list of QObject from QObjectList in javascript?
Looks like "forEach" is not supported.
Thank you.
-
A standard loop should work fine:
for (var i = 0; i < list.length; ++i) { console.log(list[i]) }
Also, try Qt 5.12.1, JS support was improved there, perhaps forEach would work.
-
-
@zosskr said in [QObjectList] Cannot read property 'forEach' of null in javascript:
I think QObjectList is not supported in 5.12.0 for JS.
QObjectList is definitely supported by QJSEngine in Qt 5.12.
How did you pass the list into JavaScript?
I already verified the object is valid.
How did you do that?
-
@zosskr
I am with @JKSH on this: how do you actually know the object is valid? Because when JS says"Cannot read property 'forEach' of null" error message from javascript when I try to list of QObjectList using forEach.
that (should) mean that the lhs of whatever you are calling
forEach()
on has the valuenull
....