Recently added to the batch used NodeInstantiator entity
beginning with the collapse of the program has been
an error code is as follows:
// main.qml
ApplicationWindow {
......
Loader {
id: root_loader
}
......
Connections {
target: manage_system
onSystemInited: root_loader.source = "MainWindow.qml"
}
......
}
// MainWindow.qml
Rectangle {
Scene3D {
id: scene_3d
aspect: ["logic", "input]
entity: SceneEntity {
......
NodeInstantiator {
model: 2
delegate: Entity {
......
}
}
......
}
}
}
This code structure substantially similar to the above, for simplicity of the model can be written NodeInstantiator 2
manage_system is c ++ to write a QObject subclass, store some load incoming data
It emits a signal manage_system systemInited initialization is complete.
Loader is because with hope after manage_system complete initialization, go to load some controls (information depends on manage_system)
However, the collapse of the reasons for the program is to use the Loader, into the following structure like this
// MainWIndow.qml
Rectangle {
Connections {
target: root_loader
onLoaded: instantiator.model = 2
}
Scene3D {
id: scene_3d
aspect: ["logic", "input]
entity: SceneEntity {
......
NodeInstantiator {
id: instantiator
// model: 2 /* 注意这里没有指定model,延时初始化model */
delegate: Entity {
......
}
}
......
}
}
}
I guess the problem is the first piece of code to initialize the timing instantiator premature (state parent is not yet Loader.Ready)
so specified in the model and then loaded root_loader