QML虚拟键盘“隐藏"按钮不起作用 [英] QML Virtual keyboard Hide button not working

查看:332
本文介绍了QML虚拟键盘“隐藏"按钮不起作用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如果我单击键盘上的隐藏按钮,我会遇到问题.以下是代码:

I am having a problem if I click on keyboard hide button .Following is the code :

import QtQuick 2.6
import QtQuick.Window 2.2
import QtQuick.Controls 2.2
import QtQuick.VirtualKeyboard 2.2

Window {
    visible: true
    width: 600
    height: 500
    title: qsTr("Hello World")

    TextField {
        id: textfield
        anchors.bottom:(inputPanel.visible) ? inputPanel.top : parent.bottom
        color: "#2B2C2E"
        cursorVisible: activeFocus
        selectionColor: Qt.rgba(0.0, 0.0, 0.0, 0.15)
        selectedTextColor: color
    }

    InputPanel {
        id: inputPanel
        z: 89
        anchors.bottom:parent.bottom
        anchors.left: parent.left
        anchors.right: parent.right

        visible: Qt.inputMethod.visible //** Warning here 

    }
}

以下是用例:

Below are the use-cases:

  1. 如果我按预期弹出了 TextField 键盘,但是当我单击隐藏键盘"按钮时,它是未隐藏.

  1. If i click on TextField keyboard pops as expected but when I click on hide keyboard button it's not hiding.

如果我按预期弹出了 TextField 键盘,那么接下来,如果我双击 TextField ,然后单击隐藏键盘"按钮,则它<.

If i click on TextField keyboard pops as expected, next if I double-click on TextField and then click on hide keyboard button it's hiding.

我也收到警告:

QML InputPanel:为属性"visible"检测到绑定循环

QML InputPanel: Binding loop detected for property "visible"

请提出建议.

推荐答案

我不知道是什么问题,但是当我在 TextInput 内添加 TextField 时,一切开始了工作,下面是代码:

I don't know what was the issue but when I added the TextField inside TextInput everything started to work,Below is the code :

TextInput {
    width:300
    height:50
    id: textfield
    anchors.bottom:(inputPanel.visible) ? inputPanel.top : parent.bottom
    color: "#2B2C2E"           

    TextField{
        width:parent.width
        height:parent.height
    }

这篇关于QML虚拟键盘“隐藏"按钮不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆