本页内容

KeyboardLayoutLoader QML Type

支持动态加载键盘布局。更多...

Import Statement: import QtQuick.VirtualKeyboard.Components
Since: QtQuick.VirtualKeyboard 1.1
Inherits:

Loader

属性

方法

详细说明

此类型适用于由多页按键组成的键盘布局。

通过将该组件用作容器来定义单个键盘布局(即一页)。随后,可通过将 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 属性中列出的布局之间的切换。

© 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.