我的代码:如果Loader的sourceComponent试题参考其母公司,和我设置“loader.active =假”,我得到一个错误
import QtQuick 2.6
import QtQuick.Window 2.2
Window {
visible: true
width: 640
height: 480
Item {
id: loaderParent
Loader {
id: loader
active: true
sourceComponent: Item {
parent: loaderParent
x: parent.x
}
}
}
Item {
focus: true
Keys.onPressed: {
loader.active = false;
}
}
}
当我按下任意键,我得到这个错误:
qrc:/main.qml:16: TypeError: Cannot read property of null
想到我怀疑这个错误是无害的,我想要一个解释或任何想法的修复/解决方法?
报告了here。
我还对其他答案留了言,但只为那些只看到这个答案的人,这里有一些相关的错误报告:https://bugreports.qt.io/browse/QTBUG-60344,https: //bugreports.qt.io/browse/QTBUG-51995。 – Mitch