How to direct keyboard input QOpenGLWindow in 5.6

杀马特。学长 韩版系。学妹 提交于 2020-01-07 02:03:01

问题


I converted my Qt application from Qt 5.3 to 5.6. Previously I used to use QGLWidget and now upgraded to QOpenGLWindow contained in a QWidget. I would like my window to handle some key press events. QOpenGLWindow does have protected methods to handle the keyboard events. However, as opposed to the old QGLWidget, it does not have setFocus() method and my handlers are not being called. What is the remedy? Even when I tried to resort to setting focus to the owning container then manually piping events to QOpenGLWindow, no events seem to come.


回答1:


I managed to solve the problem by adding eventFilter to my subclass of QOpenGLWindow and then installing event filter for the owning container (and some of its parents).



来源:https://stackoverflow.com/questions/37196155/how-to-direct-keyboard-input-qopenglwindow-in-5-6

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!