I am using QML for developing a front end and I have an issue accessing a component from my main QML Window. So, my main QML window is something as:
ApplicationWindow {
id: rootWindow
objectName: "window"
property Component mainScreen: MainScreen {} // my component
// This is a slot that gets called from C++ side.
// The function gets called fine.
function videoDone() {
mainScreen.doVideo()
}
}
The MainScreen component is written in MainScreen.qml file as:
ControlView {
id: mainScreenView
objectName: "MainScreenView"
function doVideo() {
console.log("Called")
}
}
However, this does not work as expected and I get the error:
TypeError: Property 'doVideo' of object QQmlComponent is not a function
I think the issue is that the full definition of MainScreen is not being seen at the ApplicationWindow level. I tried to see if I can cast it but no success.
Also mainScreen.objectName returns a null string rather than MainScreenView