简体   繁体   English

PyQt5/pyqt4 是否已经支持带有手写识别功能的 QtVirtualKeyboard?

[英]Does PyQt5/pyqt4 already supports QtVirtualKeyboard with Handwriting Recognition?

I'm working on a desktop application using pyqt5, and I want to use a Virtual Keyboard with Handwriting Recognition.我正在使用 pyqt5 开发桌面应用程序,我想使用具有手写识别功能的虚拟键盘。 I saw that Qt, QtVirtualKeyboard already support it.我看到 Qt,QtVirtualKeyboard 已经支持它。

Here's a link !这是一个链接

在此处输入图片说明

I got the C++ Qt example code running on QtCreator.我在 QtCreator 上运行了 C++ Qt 示例代码。 But using python3.5 and PyQt5 it gives this message:但是使用 python3.5 和 PyQt5 它会给出以下消息:

module "QtQuick.VirtualKeyboard" is not installed 
 import QtQuick.VirtualKeyboard 2.1 

How should I go on from here?我应该如何从这里继续? Does PyQt5 comes with VirtualKeyboard module? PyQt5 是否带有 VirtualKeyboard 模块? if no How to install it on PyQt5?如果没有如何在 PyQt5 上安装它?

for qt desinger you can add only this line on your .py file.对于 qt desinger,您只能在 .py 文件中添加这一行。

os.environ["QT_IM_MODULE"] = "qtvirtualkeyboard"

but If you want use QML with qtvirtualkeyboard;但是如果你想在 qtvirtualkeyboard 中使用 QML

There is no virtualkeyboard plugin in pyqt5.8, you must be use qt's paths. pyqt5.8中没有虚拟键盘插件,你必须使用qt的路径。

For a example, basic steps for pyqt5, qt5.8 and qtvirtualkeyboard installiation on ubuntu:例如,在ubuntu上安装pyqt5、qt5.8和qtvirtualkeyboard的基本步骤:

1.step install qt5.8 with qtvirtualkeyboard 1.step 使用 qtvirtualkeyboard 安装 qt5.8

wget http://download.qt.io/official_releases/qt/5.8/5.8.0/qt-opensource-linux-x64-5.8.0.run wget http://download.qt.io/official_releases/qt/5.8/5.8.0/qt-opensource-linux-x64-5.8.0.run

chmod +x qt-opensource-linux-x64-5.8.0.run chmod +x qt-opensource-linux-x64-5.8.0.run

./qt-opensource-linux-x64-5.8.0.run ./qt-opensource-linux-x64-5.8.0.run

2.step 2.步骤

apt-get install python3 python3-pip pip3 install pyqt5 apt-get 安装 python3 python3-pip pip3 安装 pyqt5

3.step 3.步骤

set environmental variables your qt paths on your python code.在python代码上设置qt路径的环境变量。

import sys, os
os.environ["QT_DIR"] = "/opt/Qt5.8.0/5.8/gcc_64"
os.environ["QT_QPA_PLATFORM_PLUGIN_PATH"] = "/opt/Qt5.8.0/5.8/gcc_64/plugins/platforms"
os.environ["QT_PLUGIN_PATH"] = "/opt/Qt5.8.0/5.8/gcc_64/plugins"
os.environ["QML_IMPORT_PATH"] = "/opt/Qt5.8.0/5.8/gcc_64/qml"
os.environ["QML2_IMPORT_PATH"] = "/opt/Qt5.8.0/5.8/gcc_64/qml"
os.environ["QT_IM_MODULE"] = "qtvirtualkeyboard"

#print(os.environ) 

from PyQt5.QtCore import *
from PyQt5 import QtCore
from PyQt5.QtWidgets import *
from PyQt5.QtQuick import *


class keyboardapp(object):
    def __init__(self):
        self.view = QQuickView()
        self.view.setObjectName("View")
        #self.view.setFlags(Qt.FramelessWindowHint)
        self.view.setSource(QUrl("main.qml"))
        self.view.setResizeMode(QQuickView.SizeRootObjectToView)
        #self.Screen = self.view.rootObject()
        #print("Screen(Root) = " + str(self.Screen))
        self.view.show()

app = QApplication(sys.argv)
test = keyboardapp()
sys.exit(app.exec_())

I been stuck with this too, and i am new to Qt After some researching, and digging in source code, found the solution我也被困在这个问题上,我是 Qt 的新手 经过一些研究和挖掘源代码,找到了解决方案

You dont need to import it to use it since its a module it will implement itself to every qt input您不需要导入它来使用它,因为它是一个模块,它将为每个 qt 输入实现自己

Well you dont need to install it on PyQt5 but on Qt5 if it is not already come with your Qt package, if you use archlinux you can install it with pacman好吧,您不需要在 PyQt5 上安装它,但是在 Qt5 上,如果您的 Qt 包尚未附带它,如果您使用 archlinux,则可以使用 pacman 安装它

pacman -S qt5-virtualkeyboard

If you cannot find it in you os repositories try to build it here is documantation https://doc.qt.io/qt-5/qtvirtualkeyboard-index.html如果您在操作系统存储库中找不到它,请尝试在此处构建它是文档https://doc.qt.io/qt-5/qtvirtualkeyboard-index.html

Then to use it in your pyqt application, set environmental variable QT_IM_MODULE to "qtvirtualkeyboard" either from your bash or inside the top your script like然后在你的 pyqt 应用程序中使用它,将环境变量QT_IM_MODULE设置为“qtvirtualkeyboard”,无论是从你的 bash 还是在你的脚本顶部

import os
os.environ["QT_IM_MODULE"] = "qtvirtualkeyboard"

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM