Qt虚拟键盘[PyQt 5.8]-找不到样式,无法调整虚拟键盘的大小

本文探讨了如何在Qt项目中自定义虚拟键盘的样式和布局,包括环境变量的正确设置、自定义.qml文件的位置以及如何避免常见错误。

我一直在尝试使用Qt虚拟键盘,并且一直运行得很好。


问题是:

  1. 设置环境变量。
  2. QT_VIRTUALKEYBOARD_STYLE(未找到)。我已经从另一个stackoverflow帖子中创建了自己的样式,看起来不错,但是没有找到。

警告:Cannot find style ".../INTERACT/interact-ii/tools/en_GB/customkb.qml" - fallback: "default"

一些尝试:

  1. 已经将customkeyboard.qml单独文件放在我自己的项目中,并将变量设置为其路径。
  2. 修改后,将整个文件夹“ en_GB”从项目中的默认Qt文件夹中放入。
  3. 还使用我的样式将变量设置为Qt文件夹中的原始路径。
  4. 下载了Qt 5.8 / 5.7 / 5.6,并对所有qtvirtualkeyboard进行了相同的操作。
  5. 看到上述错误(备用:“默认”)后,我尝试将qml项目从qt文件夹添加到default.qml。[... / Qt / 5.8 / Src / qtvirtualkeyboard / src / virtualkeyboard / content / styles / default]
  6. 用QTCreator打开了qtvirtualkeyboard.so文件,并在更改我的qml文件后构建了所有文件,以查看它是否可以更改某些内容,并且没有任何更改。

他们似乎都没有修改我的键盘大小和位置。

 

以下是一个重要示例的文件。

1-使用键盘的小示例2-我的customkeyboard.qml

import os
import sys

from PyQt5.QtCore import QProcessEnvironment
from PyQt5.QtWidgets import QApplication
from PyQt5.QtWidgets import QLineEdit
from PyQt5.QtWidgets import QMainWindow
from PyQt5.QtWidgets import QVBoxLayout
from PyQt5.QtWidgets import QWidget

os.environ["QT5DIR"] = "/home/epson/Qt/5.8/gcc_64"
os.environ["QT_QPA_PLATFORM_PLUGIN_PATH"] = "/home/epson/Qt/5.8/gcc_64/plugins/platforms"
os.environ["QT_PLUGIN_PATH"] = "/home/epson/Qt/5.8/gcc_64/plugins"
os.environ["QML_IMPORT_PATH"] = "/home/epson/Qt/5.8/gcc_64/qml"
os.environ["QML2_IMPORT_PATH"] = "/home/epson/Qt/5.8/gcc_64/qml"

os.environ["QT_VIRTUALKEYBOARD_LAYOUT_PATH"] = "/home/epson/INTERACT/interact-ii/tools/en_GB/customkb.qml"
os.environ["QT_VIRTUALKEYBOARD_STYLE"] = "/home/epson/Qt/5.8/Src/qtvirtualkeyboard/src/virtualkeyboard/content/styles"
os.environ["QT_IM_MODULE"] = "qtvirtualkeyboard"

for i in QProcessEnvironment.systemEnvironment().keys():
    print(i)

class MainWindow(QMainWindow):

    def __init__(self):
        super(MainWindow, self).__init__()
        self.line_edit = None


        self.init_ui()

    def init_ui(self):
        self.line_edit = QLineEdit()
        self.line_edit2 = QLineEdit()
        self.layout = QVBoxLayout()
        self.main_widget = QWidget()
        self.main_widget.setLayout(self.layout)
        self.layout.addWidget(self.line_edit)
        self.layout.addWidget(self.line_edit2)
        self.setCentralWidget(self.main_widget)


if __name__ == "__main__":
    app = QApplication(sys.argv)
    mw = MainWindow()
    mw.show()
    sys.exit(app.exec_())

2-我的customkeyboard.qml 

/****************************************************************************
**
** Copyright (C) 2016 The Qt Company Ltd.
** Contact: https://www.qt.io/licensing/
**
** This file is part of the Qt Virtual Keyboard module of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:GPL$
** Commercial License Usage
** Licensees holding valid commercial Qt licenses may use this file in
** accordance with the commercial license agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
** a written agreement between you and The Qt Company. For licensing terms
** and conditions see https://www.qt.io/terms-conditions. For further
** information use the contact form at https://www.qt.io/contact-us.
**
** GNU General Public License Usage
** Alternatively, this file may be used under the terms of the GNU
** General Public License version 3 or (at your option) any later version
** approved by the KDE Free Qt Foundation. The licenses are as published by
** the Free Software Foundation and appearing in the file LICENSE.GPL3
** included in the packaging of this file. Please review the following
** information to ensure the GNU General Public License requirements will
** be met: https://www.gnu.org/licenses/gpl-3.0.html.
**
** $QT_END_LICENSE$
**
****************************************************************************/

import QtQuick 2.0
import QtQuick.Window 2.2
import QtQuick.VirtualKeyboard 2.1
import "content"

Item {
    width: 1280
    height: 720

    Item {
        id: appContainer
        width: Screen.width < Screen.height ? parent.height : parent.width
        height: Screen.width < Screen.height ? parent.width : parent.height
        anchors.centerIn: parent
        rotation: Screen.width < Screen.height ? 90 : 0
        Basic {
            id: virtualKeyboard
            anchors.left: parent.left
            anchors.top: parent.top
            anchors.right: parent.right
            anchors.bottom: inputPanel.top
        }

        /*  Handwriting input panel for full screen handwriting input.

            This component is an optional add-on for the InputPanel component, that
            is, its use does not affect the operation of the InputPanel component,
            but it also can not be used as a standalone component.

            The handwriting input panel is positioned to cover the entire area of
            application. The panel itself is transparent, but once it is active the
            user can draw handwriting on it.
        */
        HandwritingInputPanel {
            z: 79
            id: handwritingInputPanel
            anchors.fill: parent
            inputPanel: inputPanel
            Rectangle {
                z: -1
                anchors.fill: parent
                color: "black"
                opacity: 0.10
            }
        }

        /*  Container area for the handwriting mode button.

   

问题:

我在设置STYLE和LAYOUT变量方面做错了吗?我应该真正设置这两者中的哪一个,是STYLE还是LAYOUT变量会改变键盘的大小和位置?我应该在哪里真正放置qml文件?我究竟做错了什么?看不出是什么问题!!

 

我相信您会混淆样式的布局,这会给您带来一些问题。

布局(Layouts

  1. en_GB目录中的.qml文件是Qt用于键盘布局的文件
  2. 要包含自定义布局,必须将QT_VIRTUALKEYBOARD_LAYOUT_PATH变量指向为自定义布局创建的目录(例如QT_VIRTUALKEYBOARD_LAYOUT_PATH = /path/to/custom/keyboard-layout/mycustomlayout)。然后,要添加英式英语的自定义布局,您将在/path/to/custom/keyboard-layout/mycustomlayout中创建一个en_GB目录。在您的en_GB目录中,至少应具有main.qml。
  3. 您已将文件命名为customkeyboard.qml。为了让Qt来正确定位,加载和处理您的自定义布局,您必须遵循默认布局(即main.qml,handwriting.qml,symbols.qml)的文件命名约定,作为参考这里

样式(Styles

对于自定义样式,您必须将自定义样式目录放在$$[QT_INSTALL_QML]/QtQuick/VirtualKeyboard/Styles中,如此处所述。显然,您的自定义style.qml文件位于自定义样式目录中。

希望这可以帮助您澄清一些事情。

为了澄清起见,QT_VIRTUALKEYBOARD_LAYOUT_PATH应将其设置为en_GB的包含文件夹。为了确认您已经为布局正确设置了所有设置,我只需要交换前两个键main.qml(例如,用“ W”代替“ Q”),以验证Qt是否正在使用您打算操纵的布局。在中定义位置,大小等style.qml。这个文件应该被放置在$$[QT_INSTALL_QML]/QtQuick/VirtualKeyboard/Styles/YourCustomStyleNameGoesHere/style.qmlQT_VIRTUALKEYBOARD_STYLE设置为$$[QT_INSTALL_QML]/QtQuick/VirtualKeyboard/Styles/YourCustomStyleNameGoesHere

虚拟键盘 软键盘 free virtual keyboard ==================== 将英语译成中文 免费多语言虚拟屏幕键盘 屏幕上的所有虚拟键工作只是因为他们如果你是一个标准的电脑键盘打字。选择键和免费的虚拟键盘发送到一个文字处理器,电子邮件,网页或其他Windows应用程序可能正在使用。键盘可以移动屏幕上的任何地方,可以是任意大小。 免费的虚拟键盘可用于残疾,防止他或她从一个物理电脑键盘打字的人。 也与我们的虚拟键盘,你可以: 改变键盘尺寸。 更改键盘的透明度。 打开和关闭一个键复读功能(见上下文菜单)。 规模的虚拟键盘以匹配屏幕宽度(见上下文菜单)。这是一个在纵向和横向模式频繁屏幕旋转有用的功能。 更改键盘(见上下文菜单)的类型。可用3虚拟键盘类型。 更改主题颜色(见上下文菜单)。 任何语言中键入文本。 键入文本(例如左手美国德沃夏克)其他布局。 -------------------------------------------------- ------------------------------ 免费的虚拟键盘是为个人和商业使用免费程序。这个节目作为分发的依据,且无任何担保,甚至没有适销性或针对特定目的的隐含的担保。舒适软件集团不能作出对任何直接或间接造成的破坏计划。 舒适软件集团保留权利更改日后发牌条件。 朗读 显示对应的拉丁字符的拼音新! 点击上方的字词即可查看其他翻译。 删除 字典 - 查看字典详细内容
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值