Qt 锁屏
从过去的一周开始,我一直在努力解决这个问题。我无法锁定我创建的任何页面的屏幕。我试着放计时器。但是我不知道该如何检测用户是否处于非活动状态。 例如 ex1.qml 如果用户在一段时间内未处于活动状态,则应用程序应要求输入密码并将其解锁。如果用户在2分钟内未按enter键,则应锁定屏幕并询问密码。 怎么做Qt 锁屏,qt,qml,Qt,Qml,从过去的一周开始,我一直在努力解决这个问题。我无法锁定我创建的任何页面的屏幕。我试着放计时器。但是我不知道该如何检测用户是否处于非活动状态。 例如 ex1.qml 如果用户在一段时间内未处于活动状态,则应用程序应要求输入密码并将其解锁。如果用户在2分钟内未按enter键,则应锁定屏幕并询问密码。 怎么做 我在等你的答复。提前感谢。您可以尝试以下内容: FocusScope{ height: 500; width:500; focus: true; Rectangl
我在等你的答复。提前感谢。您可以尝试以下内容:
FocusScope{
height: 500;
width:500;
focus: true;
Rectangle {
id:ex1
color:"red"
focus: ex1.visible;
visible:true;
anchors.fill: parent;
Keys.onEnterPressed: {
lockTimer.restart();
}
Keys.onReturnPressed:{
lockTimer.restart();
}
}
Rectangle {
id:ex2
color:"blue";
focus: !ex1.visible;
visible: !ex1.visible;
anchors.fill: parent;
Keys.onReturnPressed:{
password.opacity=1;
}
Text {
id: password;
anchors.centerIn: parent
opacity: 0;
text: "Enter Password"
}
}
Timer{
id:lockTimer;
repeat: false;
onTriggered: {
ex2.visible=true;
ex1.visible=false;
}
}
function setTimer(val){
lockTimer.interval=60000*val;
}
Component.onCompleted: {
setTimer(2);
lockTimer.start();
}
}谢谢……)这有帮助:):)
FocusScope{
height: 500;
width:500;
focus: true;
Rectangle {
id:ex1
color:"red"
focus: ex1.visible;
visible:true;
anchors.fill: parent;
Keys.onEnterPressed: {
lockTimer.restart();
}
Keys.onReturnPressed:{
lockTimer.restart();
}
}
Rectangle {
id:ex2
color:"blue";
focus: !ex1.visible;
visible: !ex1.visible;
anchors.fill: parent;
Keys.onReturnPressed:{
password.opacity=1;
}
Text {
id: password;
anchors.centerIn: parent
opacity: 0;
text: "Enter Password"
}
}
Timer{
id:lockTimer;
repeat: false;
onTriggered: {
ex2.visible=true;
ex1.visible=false;
}
}
function setTimer(val){
lockTimer.interval=60000*val;
}
Component.onCompleted: {
setTimer(2);
lockTimer.start();
}