我想将信号从一个 qml 文件传递到另一个 qml 文件。这样当它收到信号时,我可以使另一个文件可见 这是我的 main.qml
import QtQuick 1.1
Rectangle{
id:main
width:480
height:272
gradient: Gradient {
GradientStop { position: 0.0; color: "light blue" }
GradientStop { position: 1.0; color: "blue" }
}
Welcome{
id:welcomePage
width:parent.width
height:parent.height
visible:true
}
LoginPage{
id:login
width:parent.width
height:parent.height
visible:false
}
Connections{
ignoreUnknownSignals: true
onsigLogin:{welcomePage.visible=false
login.visible=true
}
}
}
这是我的welcome.qml
import QtQuick 1.1
Rectangle{
id:welcome
width:480
height:272
signal sigLogin()
gradient: Gradient {
GradientStop { position: 0.0; color: "light blue" }
GradientStop { position: 1.0; color: "blue" }
}
Text{
text:"\n\t\tPRESS ENTER"
font.bold:true
font.pointSize: 17
}
Button {
id: wel
height:30;
x:parent.width/2-30
y:parent.height/2-30
focus:true
border.color:"black"
opacity: activeFocus ? 1.0 : 0.5
Text{
text:"WELCOME"
anchors.horizontalCenter:wel.horizontalCenter;
anchors.verticalCenter:wel.verticalCenter;
}
Keys.onReturnPressed: {
wel.focus=false
welcome.sigLogin()
}
}
}
当我运行它时,我收到以下错误
file:///home/sakshi/try1/main.qml:24:9: Cannot assign to non-existent property "onsigLogin"
onsigLogin:{welcomePage.visible=false
^
谁能建议我如何从一个文件传递信号以及在收到该信号时如何进行更改?