当我显示键盘时,动画不起作用

时间:2017-01-09 04:49:23

标签: c++ qt keyboard qml

我在QML项目中遇到了一个非常混乱的问题,我设置了两个动画来显示/最小化我的窗口:

  • 显示动画后,我将显示一个微软视觉键盘。

  • 在最小化动画后,我将隐藏键盘。

这里出现了一个问题,如果我显示键盘,它将影响最小化动画。当我想开始隐藏动画时,动画会快速闪烁并完成。如果我删除showkeyboard()函数,它运行良好。

showkeyboard()函数是我调用一些c ++ api来显示微软视觉键盘。

这是我的一些代码:

PropertyAnimation {
    id: initWindow
    target: root
    from: 0
    to: mat.height
    property: 'height'
    duration: 1000
    easing.type: Easing.InOutQuad
    onRunningChanged: {
        console.log("root.visibility in initWindow:",root.visibility);
        if(!initWindow.running && root.visibility != Window.Hidden){
            inputKit.showKeyboard()
            console.log("here is initWindow animation.")
        }
    }
}

PropertyAnimation  {
    id: closeWindow
    target: root
    property: "height"
    from: mat.height
    to: 0
    duration: 1000
    easing.type: Easing.InOutQuad
    onRunningChanged: {
        if(!closeWindow.running){
            inputKit.hidekeyboard();
            root.hide();
            console.log("here is closewindow animation.")
            console.log("root.visibility in closeWindow:",root.visibility);
        }
    }
}
function minimizeWindow(){
    closeWindow.start();
    hiding();
}

function showWindow(){
    root.x = mat.x;
    root.y = mat.y;
    root.width = mat.width;
    root.height = mat.height;
    root.requestActivate();
    root.requestUpdate();
    initWindow.start();
    root.show();
    showing();
}

enter image description here

0 个答案:

没有答案