PyQt5/pyqt4 是否已经支持带有手写识别功能的 QtVirtualKeyboard? [英] Does PyQt5/pyqt4 already supports QtVirtualKeyboard with Handwriting Recognition?

查看:100
本文介绍了PyQt5/pyqt4 是否已经支持带有手写识别功能的 QtVirtualKeyboard?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用 pyqt5 开发桌面应用程序,我想使用具有手写识别功能的虚拟键盘.我看到 Qt,QtVirtualKeyboard 已经支持了.

这里是

我在 QtCreator 上运行了 C++ Qt 示例代码.但是使用 python3.5 和 PyQt5 它给出了这个消息:

模块QtQuick.VirtualKeyboard"未安装导入 QtQuick.VirtualKeyboard 2.1

我应该如何从这里继续?PyQt5 是否带有 VirtualKeyboard 模块?如果没有如何在 PyQt5 上安装它?

解决方案

对于 qt desinger,您只能在 .py 文件中添加这一行.

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

但是如果你想使用 QML 和 qtvirtualkeyboard;

pyqt5.8没有虚拟键盘插件,必须使用qt的路径.

以ubuntu上pyqt5、qt5.8和qtvirtualkeyboard安装的基本步骤为例:

1.step install qt5.8 with qtvirtualkeyboard

<块引用>

wgethttp://下载.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

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

2.步骤

<块引用>

apt-get install python3 python3-pippip3 安装 pyqt5

3.步骤

在你的python代码上设置你的qt路径的环境变量.

import sys, osos.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)从 PyQt5.QtCore 导入 *从 PyQt5 导入 QtCore从 PyQt5.QtWidgets 导入 *从 PyQt5.QtQuick 导入 *类键盘应用程序(对象):def __init__(self):self.view = QQuickView()self.view.setObjectName("视图")#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)测试 = 键盘应用程序()sys.exit(app.exec_())

I'm working on a desktop application using pyqt5, and I want to use a Virtual Keyboard with Handwriting Recognition. I saw that Qt, QtVirtualKeyboard already support it.

Here's a link!

I got the C++ Qt example code running on QtCreator. But using python3.5 and PyQt5 it gives this message:

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

How should I go on from here? Does PyQt5 comes with VirtualKeyboard module? if no How to install it on PyQt5?

解决方案

for qt desinger you can add only this line on your .py file.

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

but If you want use QML with qtvirtualkeyboard;

There is no virtualkeyboard plugin in pyqt5.8, you must be use qt's paths.

For a example, basic steps for pyqt5, qt5.8 and qtvirtualkeyboard installiation on ubuntu:

1.step install qt5.8 with qtvirtualkeyboard

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

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

2.step

apt-get install python3 python3-pip pip3 install pyqt5

3.step

set environmental variables your qt paths on your python code.

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_())

这篇关于PyQt5/pyqt4 是否已经支持带有手写识别功能的 QtVirtualKeyboard?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆