KeyboardLayout QML Type
键盘布局。更多...
| Import Statement: | import QtQuick.VirtualKeyboard.Components |
| Inherits: |
属性
- inputMethod : var
- inputMode : int
- keyWeight : real
- sharedLayouts : var
- smallTextVisible : bool
(since QtQuick.VirtualKeyboard 2.0)
方法
详细说明
此类型是键盘布局的根元素。使用此元素来构建新的键盘布局。
示例:
import QtQuick
import QtQuick.Layouts
import QtQuick.VirtualKeyboard
// file: layouts/en_GB/main.qml
KeyboardLayout {
KeyboardRow {
Key {
key: Qt.Key_Q
text: "q"
}
Key {
key: Qt.Key_W
text: "w"
}
Key {
key: Qt.Key_E
text: "e"
}
Key {
key: Qt.Key_R
text: "r"
}
Key {
key: Qt.Key_T
text: "t"
}
Key {
key: Qt.Key_Y
text: "y"
}
}
}属性文档
inputMethod : var
设置在此布局中使用的输入法。
此属性允许在此布局中使用自定义输入法。
inputMode : int
设置此布局中要使用的输入模式。
默认情况下,虚拟键盘在切换到其他键盘布局时会尝试保留当前的输入模式。
如果当前输入模式在当前上下文中无效,则由输入法指定默认输入模式。
keyWeight : real
设置所有子键的权重。
默认值从布局层次结构中的父元素继承而来。
sharedLayouts : var
共享由createInputMethod()函数创建的输入法的布局名称列表。
如果该列表为空(默认情况),则该输入法不会与其他任何布局共享,且在布局发生变化时将被销毁。
该列表应仅包含布局类型的名称,例如 ['symbols']。当前布局不必包含在列表中。
smallTextVisible : bool [since QtQuick.VirtualKeyboard 2.0]
为所有子键设置smallTextVisible 属性。
默认值继承自布局层次结构中的父元素。
该属性在 QtQuick.VirtualKeyboard 2.0 中引入。
方法文档
createInputMethod()
键盘布局可以重写此函数,以动态创建输入法对象。默认实现返回null 。
在某些情况下,由该函数创建的输入法对象的存活时间可能超过键盘布局的切换。特别是,这适用于sharedLayouts 属性中列出的布局之间的切换。
© 2026 The Qt Company Ltd. Documentation contributions included herein are the copyrights of their respective owners. The documentation provided herein is licensed under the terms of the GNU Free Documentation License version 1.3 as published by the Free Software Foundation. Qt and respective logos are trademarks of The Qt Company Ltd. in Finland and/or other countries worldwide. All other trademarks are property of their respective owners.