Ok, it appears that I was overcomplicating this a bit :-) The simple solution just creating a normal QWindow with a parent created from QWindow::fromWinId((WId)hwnd).
At least this works just as I needed, although the documentation for QWindow::setParent() should probably be updated? At least, the way I read it, reparenting to a native window is only supported in X11 (last paragraph): "If *parent* is a window created by fromWinId<http://qt-project.org/doc/qt-5/qwindow.html#fromWinId>(), then the current window will be embedded inside *parent*, if the platform supports it. Window embedding is currently supported only by the X11 platform plugin." - Thomas On Thu, Jan 30, 2014 at 12:51 PM, Thomas Sevaldrud <tho...@silentwings.no>wrote: > Hi, > > I'm trying to use QGLContext to render into a native Win32 window, and I'm > wondering what'ts the best way to do this. What I've done this far is the > following: > > Given a natively created window with a valid HWND, I Create a QWindow with > the following parameters: > > setSurfaceType(QWindow::OpenGLSurface); > > setFlags(Qt::ForeignWindow); > > setProperty("_q_foreignWinId", QVariant::fromValue((WId)hwnd)); > > > The native window is already open, but I need to call show() on the > QWindow to trigger the Qt native window structures. > > After this, I can create a QGLContext and make it current in the custom > QWindow, and I can even render to it, but I get a lot of warnings like these > > QOpenGLContext::swapBuffers() called with non-exposed window, behavior is > undefined > > > It appears that the "exposed" flag is never set in the custom QWindow. > > Any ideas how I can fix this? I can't find any convenient way to force the > expose flag in a QWindow. Or is there a cleaner way to achieve this? > > Best regards, > Thomas >
_______________________________________________ Interest mailing list Interest@qt-project.org http://lists.qt-project.org/mailman/listinfo/interest