First, we ask the JS engine to create a new JavaScript array object. Then, we iterate over all entities and skip entities that were already killed. We use QJSValue::setProperty to add the proxy object of each entity to the array. We need to specify the index of the new array item, so we create the arrayIndex counter and increment it after each insertion. Finally, we return the array.
This function completes the SceneProxy class implementation. We just need to create a proxy object and add it to the JS engine in the constructor of the Scene class:
SceneProxy *sceneProxy = new SceneProxy(this); m_sceneProxyValue = m_jsEngine.newQObject(sceneProxy);