Important: Please read the Qt Code of Conduct -

QGLWidget::updateGL not working on Windows

  • I recently compiled the newest version of Qt on Windows using Visual Studio compiler. I have a class that inherits QGLWidget. I have a loop which calls updateGL() on an object from that class. It works (refreshes the gl window) on mac, and worked on windows when I was using Qt Creator and minGW with a previous version of Qt. But now using Visual Studio compiler, and a newly compiled version of Qt, it does not refresh the opengl screen when I call that function. I did notice that it does refresh the screen when I alt-tab to a new window.

    I realize there could be loads of reasons why this is happening, but if anyone will help me find the source I would be eternally grateful. I know next to nothing about visual studio, windows, or compilers, and it looks like the problem has something to do with those(or maybe Qt implementation). Also, I should mention, I did add some boost(v. 1.44 on windows) objects, using asio, date_time, thread, and regex. I doubt it is causing the problem, but thought I should mention it.

  • i seem to remember (but i'm not sure), that you should call update() on these classes, which internally calls the GL method... and shouldnt call the updateGL method yourself...

  • I think you are thinking of paintGL, which shouldn't be called directly. The program worked fine for weeks while using qt creator, but after recompiling qt with microsoft nmake and using nmake to compile my app it is not working correctly. I had to add windows.h to my code for gl.h to work correctly (apparently gl.h on windows contains a bunch of preprocessor variables that are defined in windows.h), could this be causing the issue?

  • update() does work, but the qt tutorials use updateGL(), so I assume that is the proper way of doing it. The program is very choppy with update().

    Also, I found some very old articles where a thread was the issue. I am calling the updateGL() within a boost::thread, which I wasn't doing before. Though, again, it still works correctly on mac ppc.

    Anyone know more about this?

  • Yes you are right about update, I re-read the docs. Without looking at some code I don't have any other ideas though, sorry.

  • I changed the boost asio timer and thread back to the QTimer for the main loop. And updateGL is working correctly. I'm new to threads, and I'm guessing that had something to do with it, though the updateGL call was the only problem I noticed.

    Thanks for the help!, though instead of trying to hunt down the issue, I'm going back to the QTimer for the loop as it worked just fine.

  • QWidgets and painting in threads is a big nono.

Log in to reply