Qt QML使用虚拟键盘示例(附完整源码)


使用"虚拟键盘"注意 (例子的Qt版本:5.12.4)

注意一:
?????/* 必须在mainpp开始处加入如下代码,否则无法使用"虚拟键盘" */
?????qputenv(“QT_IM_MODULE”,QByteArray(“qtvirtualkeyboard”));

?
注意二:
?????键盘大小是根据宽度自动计算的,所以,应用程序应该只设置InputPanel 的宽度和y 坐标,不能设置高度。

源码

?????mainpp

1 #include <QGuiApplication> 2 #include <QQmlApplicationEngine> 3 4 int main(int argc, char *argv[]) 5 , Qt::QueuedConnection); 20 engine.load(url); 21 22 return app.exec(); 23 }

main.qml

1 import QtQuick 2.12 2 import QtQuick.Window 2.12 3 import QtQuick.Layouts 1.12 4 import QtQuickontrols 2.5 5 6 import QtQuick.VirtualKeyboard 2.2 7 import QtQuick.VirtualKeyboard.Settings 2.2 8 9 Window 10 34 TextField 35 46 } 47 } 48 49 RowLayout 50 59 TextField 60 71 } 72 } 73 } 74 75 InputPanel 76 92 } 93 transitions: Transition 94 106 } 107 } 108 109 110 Cponent.onCpleted: 111 116 } 117 }



上一篇:Qt 编写的qml程序全屏时,挡住系统虚拟键盘的解决办法

下一篇:Qt 生成随机数 qrand、QRandomGenerator


Qt
Copyright © 2002-2019 k262电脑网 www.k262.cn 皖ICP备2020016292号
温馨提示:部分文章图片数据来源与网络,仅供参考!版权归原作者所有,如有侵权请联系删除!QQ:251442993 热门搜索 网站地图