KeyboardLayoutLoader QML Type
允许动态加载键盘布局。更多
Import Statement: | import QtQuick.VirtualKeyboard.Components |
Since: | QtQuick.VirtualKeyboard 1.1 |
Inherits: |
属性
- inputMethod : var
- inputMode : int
- sharedLayouts : var
方法
详细说明
该类型适用于由多页按键组成的键盘布局。
单个键盘布局(一个页面)是通过使用 Component 作为容器定义的。然后可以通过将 sourceComponent 属性设置为不同的值来更改活动键盘布局。
示例
import QtQuick import QtQuick.Layouts import QtQuick.VirtualKeyboard // file: layouts/en_GB/symbols.qml KeyboardLayoutLoader { property bool secondPage onVisibleChanged: if (!visible) secondPage = false sourceComponent: secondPage ? page2 : page1 Component { id: page1 KeyboardLayout { // Keyboard layout definition for page 1 } } Component { id: page2 KeyboardLayout { // Keyboard layout definition for page 2 } } }
属性文档
inputMethod : var |
设置此上下文中加载的所有键盘布局的输入法。
输入法可以为每个键盘布局单独设置,也可以在此上下文中共同设置。如果单独设置,则不应修改此属性。
inputMode : int |
设置此上下文中加载的所有键盘布局的输入模式。
输入模式可以为每个键盘布局单独设置,也可以在此上下文中共同设置。如果单独设置,则不应修改此属性。
sharedLayouts : var |
共享createInputMethod() 函数创建的输入法的布局名称列表。
如果该列表为空(默认值),则输入法不与任何其他布局共享,并将在布局更改时被销毁。
列表应只包含布局类型的名称,例如['symbols']。当前布局不必包含在列表中。
方法文档
createInputMethod() |
该函数可由键盘布局重载,以动态创建输入法对象。默认实现会将调用转发给子键盘布局。
在某些情况下,此函数创建的输入法对象的寿命可能会超过键盘布局转换的寿命。这尤其适用于sharedLayouts 属性中列出的布局之间的转换。
© 2025 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.