arm开发板上使用qt5.8虚拟键盘(支持中文)
2017-11-09 09:02
3019 查看
qt5.8是支持虚拟键盘的,但是不能使用拼音输入中文,但是虚拟键盘库的编译是可配置的。
以下所有过程是qt5.8源码编译、安装完成后实现的。
一、编译支持中文的虚拟键盘库(如果不需要中文,这一步可以省略)
1.进入拼音的源码目录:
cd ./qt-everywhere-opensource-src-5.8.0/qtvirtualkeyboard/src/virtualkeyboard/3rdparty/pinyin
2.qmake pinyin.pro,生成Makefile;
3.make,生成拼音的库;
4.vim qt-everywhere-opensource-src-5.8.0/qtvirtualkeyboard/src/virtualkeyboard/virtualkeyboard.pro,在Pro文件中对应的位置加入标记红色的内容:
TARGET = qtvirtualkeyboardplugin
DATAPATH = $$[QT_INSTALL_DATA]/qtvirtualkeyboard
QMAKE_DOCS = $$PWD/doc/qtvirtualkeyboard.qdocconf
include(doc/doc.pri)
QT += qml quick gui gui-private core-private
CONFIG += lang-zh_CN
CONFIG += lang-en_GB
win32 {
CONFIG += no-pkg-config
QMAKE_TARGET_PRODUCT = "Qt Virtual Keyboard (Qt $$QT_VERSION)"
QMAKE_TARGET_DESCRIPTION = "Virtual Keyboard for Qt."
}
5.cd qt-everywhere-opensource-src-5.8.0/qtvirtualkeyboard
6.qmake qtvirtualkeyboard.pro
7.make
8.sudo make install
9.将qt5.8的所有安装目录文件重新拷入开发板;
二、在程序中使用虚拟键盘
1.在程序的pro文件中加入以下内容:
static{
QTPLUGIN+=qtvirtualkeyboardplugin
QT+=svg
}
2.在main函数中加入一条语句:
qputenv("QT_IM_MODULE",QByteArray("qtvirtualkeyboard"));
以上就完成了虚拟键盘的使用,在lineEdit控件上点击,键盘就会弹出来。
弹出的虚拟键盘是一个新的窗口,会遮挡住原有的窗口,暂时未解决该问题。
官网是这样解释的:
The input
panel must be a sibling element next to the application container. It is important not to put the input panel
within the application container,
as it would
then overlap with the contents of the application. Also, the input panel height will be automatically updated
according to the available width;
the aspect
ratio of the input panel is constant.
还给出了一个实例,但是是QML文本:
import
QtQuick 2.0
import QtQuick.VirtualKeyboard 2.1
Item {
id: root
Item {
id: appContainer
anchors.left: parent.left
anchors.top: parent.top
anchors.right: parent.right
anchors.bottom: inputPanel.top
...
}
InputPanel {
id: inputPanel
y: Qt.inputMethod.visible ? parent.height - inputPanel.height : parent.height
anchors.left: parent.left
anchors.right: parent.right
}
}
可本人对QML方面的知识也不了解,只能暂时搁置。。。
以下所有过程是qt5.8源码编译、安装完成后实现的。
一、编译支持中文的虚拟键盘库(如果不需要中文,这一步可以省略)
1.进入拼音的源码目录:
cd ./qt-everywhere-opensource-src-5.8.0/qtvirtualkeyboard/src/virtualkeyboard/3rdparty/pinyin
2.qmake pinyin.pro,生成Makefile;
3.make,生成拼音的库;
4.vim qt-everywhere-opensource-src-5.8.0/qtvirtualkeyboard/src/virtualkeyboard/virtualkeyboard.pro,在Pro文件中对应的位置加入标记红色的内容:
TARGET = qtvirtualkeyboardplugin
DATAPATH = $$[QT_INSTALL_DATA]/qtvirtualkeyboard
QMAKE_DOCS = $$PWD/doc/qtvirtualkeyboard.qdocconf
include(doc/doc.pri)
QT += qml quick gui gui-private core-private
CONFIG += lang-zh_CN
CONFIG += lang-en_GB
win32 {
CONFIG += no-pkg-config
QMAKE_TARGET_PRODUCT = "Qt Virtual Keyboard (Qt $$QT_VERSION)"
QMAKE_TARGET_DESCRIPTION = "Virtual Keyboard for Qt."
}
5.cd qt-everywhere-opensource-src-5.8.0/qtvirtualkeyboard
6.qmake qtvirtualkeyboard.pro
7.make
8.sudo make install
9.将qt5.8的所有安装目录文件重新拷入开发板;
二、在程序中使用虚拟键盘
1.在程序的pro文件中加入以下内容:
static{
QTPLUGIN+=qtvirtualkeyboardplugin
QT+=svg
}
2.在main函数中加入一条语句:
qputenv("QT_IM_MODULE",QByteArray("qtvirtualkeyboard"));
以上就完成了虚拟键盘的使用,在lineEdit控件上点击,键盘就会弹出来。
弹出的虚拟键盘是一个新的窗口,会遮挡住原有的窗口,暂时未解决该问题。
官网是这样解释的:
The input
panel must be a sibling element next to the application container. It is important not to put the input panel
within the application container,
as it would
then overlap with the contents of the application. Also, the input panel height will be automatically updated
according to the available width;
the aspect
ratio of the input panel is constant.
还给出了一个实例,但是是QML文本:
import
QtQuick 2.0
import QtQuick.VirtualKeyboard 2.1
Item {
id: root
Item {
id: appContainer
anchors.left: parent.left
anchors.top: parent.top
anchors.right: parent.right
anchors.bottom: inputPanel.top
...
}
InputPanel {
id: inputPanel
y: Qt.inputMethod.visible ? parent.height - inputPanel.height : parent.height
anchors.left: parent.left
anchors.right: parent.right
}
}
可本人对QML方面的知识也不了解,只能暂时搁置。。。
相关文章推荐
- linux下使用QT5.8实现虚拟键盘
- linux下使用qt5.7及其以上版本的虚拟键盘,支持中英文输入法
- QT下使用BasicExcel 并支持中文
- QT5.8支持中文解决中文乱码
- Qt5.7以上调用虚拟键盘(支持中文),以及源码修改(可拖动,水平缩放)
- Qt5虚拟键盘-支持中文输入
- QT支持中文
- Qt Windows/Linux支持中文编码
- Robot Framework中使用HttpLibrary教程and中文支持
- 解决中文输入 Qt 针对5.8也做了说明 及4.x版本
- QT5.8 + VS2015 中文乱码解决办法
- MFC下支持中文的SQLite3封装类使用
- 【第一篇】Qt学习与使用---将数字转换成中文大写的形式
- [Bug]QT解决中文乱码(tr的使用 | QTextCodec)
- 嵌入式Qt方案中文显示系列:Qte中的字体支持和使
- 使用jquery-qrcode在页面上生成二维码,支持中文
- JS导出PDF插件的方法(支持中文、图片使用路径)
- Qt 中文支持记录
- 让汉字永远自由使用_______请支持文泉驿中文字体字库开源项目
- 使用org.apache.commons.net.ftp包开发FTP客户端,实现进度汇报,实现断点续传,中文支持