Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/qt/6.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Qt 锁屏_Qt_Qml - Fatal编程技术网

Qt 锁屏

Qt 锁屏,qt,qml,Qt,Qml,从过去的一周开始,我一直在努力解决这个问题。我无法锁定我创建的任何页面的屏幕。我试着放计时器。但是我不知道该如何检测用户是否处于非活动状态。 例如 ex1.qml 如果用户在一段时间内未处于活动状态,则应用程序应要求输入密码并将其解锁。如果用户在2分钟内未按enter键,则应锁定屏幕并询问密码。 怎么做 我在等你的答复。提前感谢。您可以尝试以下内容: FocusScope{ height: 500; width:500; focus: true; Rectangl

从过去的一周开始,我一直在努力解决这个问题。我无法锁定我创建的任何页面的屏幕。我试着放计时器。但是我不知道该如何检测用户是否处于非活动状态。 例如 ex1.qml

如果用户在一段时间内未处于活动状态,则应用程序应要求输入密码并将其解锁。如果用户在2分钟内未按enter键,则应锁定屏幕并询问密码。 怎么做


我在等你的答复。提前感谢。

您可以尝试以下内容:

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();
}