【发布时间】:2016-11-14 17:09:55
【问题描述】:
我正在尝试覆盖 QML 应用程序窗口中的 onClosing 事件。
窗口的qml很简单:
ApplicationWindow {
id: rootWindow
objectName: "window"
visible: true
width: 800
height: 480
property Component loginForm: LoginView {}
onClosing: {
loginForm.logout()
}
}
LoginView 视图也很简单:
Rectangle {
id: view
function logout() {
console.log("Logout called");
}
}
现在,它返回一个错误:
TypeError: Property 'logout' of object QQmlComponent(0x9287150) is not a function
我也尝试了loginForm.view.logout() 并返回:
TypeError: Cannot call method 'logout' of undefined
【问题讨论】: