Important: Please read the Qt Code of Conduct -

Mouse/kb events not handled until alt+tab?

  • Hi all,

    I have 5 top level windows, 1 "normal" and 4 QGLWidget-derived, running on Win7. I just switched from using QGraphicsScene to QGLWidget. The problem I face now is that, as the title says, mouse and kb input to the application get "stuck" until an alt+tab happens. I can't drag windows around or operate the max/min/close buttons. The mouse pointer is "trapped" within the area of the screen above the task bar.

    My OGL drawing is triggered by a QTimer::singleShot() which calls updateGL() on each ogl window. I can avoid the non-responsive mouse/kb behavior by pausing for 100+ ms after drawing, but that's pretty ridiculous. I'm thinking that, since pausing fixes the problem, maybe Qt's message pump is being overloaded somehow. When using QGraphicsScene, update() didn't execute drawing immediately, so perhaps Qt was handling messages in-between ogl window renders?

    The mouse trapped above the task bar behavior is puzzling.

    Any suggestions would be greatly appreciated! No idea where to even begin to debug this one...


  • Try repaint (). QGLwidget can draw on demand.

  • Hi, thanks for the suggestion! Actually repaint() causes a repaint immediately, which is what might be causing the problem.

    But in looking at the docs again, I wondered why I'm even calling updateGL() directly. Changing this to update() causes the new QGLWidget version to behave like the old version, which solves my immediate problem.

    It seems to me now, though, that all versions are overloading something, probably message handling, as the UI is sluggish. If I have time, I might look at moving gl rendering to a separate thread to keep the UI responsive.

    Thanks again!

Log in to reply