Qt VirtualKeyboard C++集成与实现(自适应位置)


一. 实现

inputcontex.h增加如下内容:

1 Q_PROPERTY(QRectF inputItemGeetry READ inputItemGeetry) 2 QRectF inputItemGeetry();

inputcontexpp增加如下内容:

1 QRectF InputContext::inputItemGeetry() 2

我们使用这个函数来获取当前控件的位置和大小信息。

InputPanel.qml增加如下内容:

1 anchors.horizontalCenter: parent.horizontalCenter 2 width: Screen.desktopAvailableWidth * 2 / 3 3 4 states: State 11 } 12 transitions: Transition 22 } 23 } 24 function getInputY() 28 else if(InputContext.inputItemGeetry.y keyboard.height 100 >= 0) 29 32 else 33 36 }

我们使用getInputY函数根据输入控件的位置和大小来调整Qt键盘的位置。

二. 效果



上一篇:Qt 开发经验常见问题及优化100条

下一篇:Qt 图例类QLegend详解


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