In my qml I'm creating a C++ component object but can't figure out how to reference the object once it's created.
Here's the qml to create an OgreScene object:
MouseArea
{
anchors.fill: parent
function scene()
{
var scene = Qt.createQmlObject( "import Client.Plugin.Ogre 0.1; OgreScene{ id: pluginScene; engine: OgreEngine }", plugin );
console.log( "qml: init scene" );
pluginScene.init();
}
onClicked: scene()
}
When I run it I get:
Qt Debug: qml: init scene
Qt Warning: qrc:///client.qml:118: ReferenceError: pluginScene is not defined
I added this to the inline qml:
import Client.Plugin.Ogre 0.1;
It cannot find the object definition without an import. This import had already been done in the qml file so it appears the inline qml is in a separate context from the file it's executed from.
How can I create a c++ component object in the same context as my qml file?