Qt VirtualKeyboard C++集成与实现(解决模态对话框键盘失效问题)


一. Qt 模态对话框

先让我们来看看对话框的几种特性:

1.Qt::NonModa

The window is not modal and does not block input to other windows.

2.Qt::WindowModal

The window is modal to a single window hierarchy and blocks input to its parent window, all grandparent windows, and all siblings of its parent and grandparent windows.

3.Qt::ApplicationModal

The window is modal to the application and blocks input to all windows.

可以看出,比较常用的exec()方法显示的对话框是属于第三种:Qt::ApplicationModal,这种对话框无法接受除了自身之外的任何其他对象的输入,而第二种Qt::WindowModal是可以接受QApplication的输入,所以我们只需将其改为第二种即可。

二. 实现

我们只需在显示键盘之前添加如下代码:

1 if(qGuiApp>focusWindow()>isModal()) 2 qGuiApp>focusWindow()>setModality(Qt::WindowModal);



上一篇:Qt QList使用总结

下一篇:Qt QLineEdit输入限制


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