On Windows, Using QWidget::createWindowContainer doesn't work for me on Qt 5.2.1

  • I made a nice little tool for myself on windows, and I had been using Qt 5.1.1 . I needed to use OpenGL and was about to use QGLWidget when i read that there is apparently a new more modern way of doing OpenGL in Qt5. Problem was i still needed the OpenGL window to be a widget in a larger application, and I read that a QOpenGLWidget is not ready yet. As a temporary measure, i decided to implement this part of my window using two classes, one derived from QWidget to contain the other class which I derive from QWindow. These are called PlotWidget and PlotWindow respectively. PlotWidget has a QWidget * which I use to point to the widget returned from the QWidget::createWindowContainer object. For now, I couldn't see any cleaner way of doing this without the QOpenGLWidget class.

    Anyway, I made my program, and then i realized that a little while ago, Qt 5.2.1 came out and i wanted to test to make sure everything still worked. Obviously, it did not. When i run the application, all of the events are called and all the logic is processed just as before, but nothing is drawn to the Widget, and i have no clue why. When i went and tested it on linux mint 15, (my current version of linux mint), all the logic worked just the same, but on neither Qt 5.1.1 or Qt 5.2.1, nothing is displayed on that window. Hop on back over to windows, everything works correctly on Windows 8 with Qt 5.1.1 . My question: Is this a bug with Qt, or is something wrong with the way I am creating the context, getting the opengl functions, setting the surface format, etc?

    Here is the relavant declarations "PlotWidget.h":http://pastebin.com/MrYce19w#

    and the constructor part of it's implementation which initializes the context and functions "PlotWidget.cpp":http://pastebin.com/BDkYrvGC

    also just in case, these are being created inside a widget call CentralPane so here is it's header and implementation.



    neither are destroyed until the end of execution. Can anyone think of any explanation for this behavior of not displaying anything in 5.2.1 on Windows or at all on Linux? If there is something stupid and obvious, bear in mind that I just learned of this new QOpenGL stuff 2 days ago. If you need to see more code from anywhere, just ask.

  • Lifetime Qt Champion

    Hi and welcome to devnet,

    If you can reproduce this with a minimal application then you might have found a regression. Have a look at the "bug report system":http://bugreports.qt-project.org to see if it something known. If not please consider opening a new report providing that minimal compilable example.

Log in to reply

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.