基于 QtWebKit 的浏览器的虚拟键盘或如何获取当前聚焦的文本字段?
我正在致力于为基于 QtWebKit 的浏览器实现虚拟键盘。我很难理解 QtWebKit 如何在实际页面中绘制控件。最初我以为它们是 QLineEdit 实例,但事实并非如此。深入研究实现,Qt 和 WebKit 之间的粘合代码似乎使用 QStyle 和 QPainter 绘制文本字段。不幸的是,我对 Qt 很陌生,所以我不明白事件循环中鼠标按下这些事件的位置被解释。我在调用堆栈深处找到了 Editor::canEdit(),现在当用户单击页面内的文本字段时,我可以调出虚拟键盘。然后,虚拟键盘需要一个指向 QWidget 实例的指针,但 Edito::canEdit() 不携带该信息,而且我找不到暴露 QWidget 实例的任何地方。我真的很困惑,非常欢迎任何建议。
谢谢!
I'm working on implementing a virtual keyboard for a QtWebKit based browser. I'm having a lot of difficulty understanding how QtWebKit paints the controls within the actual page. Initially I thought they were QLineEdit instances, but they are not. Diving into implementation it appears that the glue code between Qt and WebKit paints the text field using QStyle and QPainter. Unfortunately, I'm very new to Qt and so I dont understand where in the event loop the mouse presses for these events are interpreted. I found Editor::canEdit() deep in the call stack, and now I can bring up the virtual keyboard when the user clicks on a text field within the page. The virtual keyboard then expected a pointer to a QWidget instance, but Edito::canEdit() doesn't carry that information and I can't find anywhere where a QWidget like instance is exposed. I'm really stumped, any advice would be most welcome.
Thanks!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
通过将虚拟键盘连接到 Qt 输入法系统中,您可能会获得更好的运气。在QtWebKit Api的源代码中,即qweb*.*文件中搜索“InputMethod”。
You might get better luck by hooking the virtual keyboard into the Qt input method system. Search for "InputMethod" in the source code of QtWebKit Api, i.e. the qweb*.* files.