<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0"><channel><title><![CDATA[Rendering in QOpenGLWindow embedded in QMdiArea fails]]></title><description><![CDATA[<p dir="auto">Hi there,<br />
I'm in the process of porting an application from Qt4 to Qt5 (currently working<br />
on Debian 9 with Qt 5.7.1).<br />
The application used a QGLWidget embedded as QMdiSubwindow in a QMdiArea.<br />
As the QGLWidget is deprecated, I first tried to use the QOpenGLWidget instead.<br />
This worked fine except for stereo rendering. But stereo rendering is an absolute<br />
must for the application. QTBUG-59636 (<a href="https://bugreports.qt.io/browse/QTBUG-59636" target="_blank" rel="noopener noreferrer nofollow ugc">https://bugreports.qt.io/browse/QTBUG-59636</a>)<br />
discusses a similar issue and one of the suggestions in the thread was to use<br />
QOpenGLWindow instead of QOpenGLWidget and use QWidget::createWindowContainer<br />
to add it to the Widget hierarchy.<br />
This works, including stereo rendering, when I show the plain widget.<br />
However, if I add such a widget to the QMdiArea, rendering fails.<br />
I could not find any obvious hint in the documentation of what goes wrong here<br />
but can provide code including pro file that reproduces the issue (on my machine).<br />
Would be great if anybody can confirm that the problem exists on other setups or,<br />
even better, suggest a solution.</p>
<p dir="auto">Thanks a lot,</p>
<p dir="auto">Gabriel</p>
<p dir="auto">The code depends on OpenGL headers. If all dependencies are at their default<br />
locations you should be able to compile with:</p>
<p dir="auto">qmake<br />
make</p>
<p dir="auto">Theres a preprocessor define statement that allows to compile in four modes.<br />
For all of them I would expect a red triangle to appear in a window.<br />
This is not the case for the last one.</p>
<ul>
<li>QOpenGLWidgetMode           =&gt; The renderer is a simple QWidget that inherits<br />
from QOpenGLWidget</li>
<li>QOpenGLWindowMode           =&gt; The renderer inherits from QOpenGLWindow and is<br />
wrapped using QWidget::createWindowContainer</li>
<li>QOpenGLWidgetInQMdiAreaMode =&gt; Same as QOpenGLWidgetMode, but resulting widget<br />
is added as QMdiSubWindow to a QMdiArea</li>
<li>QOpenGLWindowInQMdiAreaMode =&gt; Same as QOpenGLWindowMode, but resulting widget<br />
is added as QMdiSubWindow to a QMdiArea<br />
THIS DOES NOT RENDER ON MY MACHINE</li>
</ul>
<p dir="auto"><strong>pro file:</strong></p>
<pre><code>######################################################################
# Automatically generated by qmake (3.0) Thu Jan 24 22:18:34 2019
######################################################################

TEMPLATE = app
TARGET = gl_bug_report
INCLUDEPATH += .
QT += widgets
LIBS += -lGL -lGLU

# Input
SOURCES += test.cc
</code></pre>
<p dir="auto"><strong>source file:</strong></p>
<pre><code>#include &lt;GL/gl.h&gt;
#include &lt;GL/glu.h&gt;
#include &lt;QApplication&gt;
#include &lt;QOpenGLWidget&gt;
#include &lt;QOpenGLWindow&gt;
#include &lt;QDebug&gt;
#include &lt;QMdiArea&gt;
#include &lt;QMdiSubWindow&gt;

template &lt;typename T&gt;
class GLRenderer : public T {
  
protected:
  virtual void initializeGL() {
    qDebug() &lt;&lt; "Enter initializeGL";  
    glDisable(GL_TEXTURE_2D);
    glDisable(GL_DEPTH_TEST);
    glDisable(GL_COLOR_MATERIAL);
    glEnable(GL_BLEND);
    glEnable(GL_POLYGON_SMOOTH);
    glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
    glClearColor(0, 0, 0, 0);
  }

  virtual void resizeGL(int w, int h) {
    qDebug() &lt;&lt; "Enter resizeGL";
    glViewport(0, 0, w, h);
    glMatrixMode(GL_PROJECTION);
    glLoadIdentity();
    gluOrtho2D(0, w, 0, h);
    glMatrixMode(GL_MODELVIEW);
    glLoadIdentity();
  }

  virtual void paintGL() {
    qDebug() &lt;&lt; "Enter paintGL";
    glClear(GL_COLOR_BUFFER_BIT);
    glColor3f(1, 0, 0);
    glBegin(GL_POLYGON);
    glVertex2f(0, 0);
    glVertex2f(100, 500);
    glVertex2f(500, 100);
    glEnd();
  }
};

/*
The define below controls how we use the GLRenderer defined above

QOpenGLWidgetMode           =&gt; The renderer is a simple QWidget that inherits 
                               from QOpenGLWidget
QOpenGLWindowMode           =&gt; The renderer inherits from QOpenGLWindow and is 
                               wrapped using QWidget::createWindowContainer
QOpenGLWidgetInQMdiAreaMode =&gt; Same as QOpenGLWidgetMode, but resulting widget 
                               is added as QMdiSubWindow to a QMdiArea
QOpenGLWindowInQMdiAreaMode =&gt; Same as QOpenGLWindowMode, but resulting widget 
                               is added as QMdiSubWindow to a QMdiArea
                               THIS DOES NOT RENDER ON MY MACHINE
*/

#define QOpenGLWidgetMode

int main(int argc, char** argv) {
  
  QApplication app(argc, argv);
  QWidget* widget;
  
  #ifdef QOpenGLWidgetMode
  qDebug() &lt;&lt; "Create widget using QOpenGLWidget";  
  qDebug() &lt;&lt; "This renders a nice triangle on my machine";    
  widget = new GLRenderer&lt;QOpenGLWidget&gt;;
  #endif

  #ifdef QOpenGLWindowMode
  qDebug() &lt;&lt; "Create widget using QOpenGLWindow and QWidget::createWindowContainer";
  qDebug() &lt;&lt; "This renders a nice triangle on my machine";  
  QWindow* window = new GLRenderer&lt;QOpenGLWindow&gt;;
  widget = QWidget::createWindowContainer(window);
  #endif
  
  #ifdef QOpenGLWidgetInQMdiAreaMode
  qDebug() &lt;&lt; "Create widget using QOpenGLWidget as subwindow in QMdiArea";  
  qDebug() &lt;&lt; "This renders a nice triangle on my machine";    
  QMdiArea* area = new QMdiArea;
  QMdiSubWindow* sub_window = area-&gt;addSubWindow(new GLRenderer&lt;QOpenGLWidget&gt;);
  sub_window-&gt;setWindowState(Qt::WindowMaximized);
  widget = dynamic_cast&lt;QWidget*&gt;(area);
  #endif
 
  #ifdef QOpenGLWindowInQMdiAreaMode
  qDebug() &lt;&lt; "Create widget using QOpenGLWidget as subwindow in QMdiArea";  
  qDebug() &lt;&lt; "Rendering fails on my machine";    
  QMdiArea* area = new QMdiArea;
  QWindow* window = new GLRenderer&lt;QOpenGLWindow&gt;;  
  QMdiSubWindow* sub_window = area-&gt;addSubWindow(QWidget::createWindowContainer(window));
  sub_window-&gt;setWindowState(Qt::WindowMaximized);
  widget = dynamic_cast&lt;QWidget*&gt;(area);
  #endif
  
  widget-&gt;show();
  return app.exec();
}
</code></pre>
]]></description><link>https://forum.qt.io/topic/99030/rendering-in-qopenglwindow-embedded-in-qmdiarea-fails</link><generator>RSS for Node</generator><lastBuildDate>Mon, 06 Apr 2026 02:25:32 GMT</lastBuildDate><atom:link href="https://forum.qt.io/topic/99030.rss" rel="self" type="application/rss+xml"/><pubDate>Mon, 28 Jan 2019 09:27:19 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to Rendering in QOpenGLWindow embedded in QMdiArea fails on Tue, 19 Feb 2019 08:23:16 GMT]]></title><description><![CDATA[<p dir="auto">Jap, might be the case. As you said, the same version downloaded through the installer works as expected... I close this topic as it seems to be a local setup problem (weird one though). Thanks for the help!</p>
]]></description><link>https://forum.qt.io/post/512404</link><guid isPermaLink="true">https://forum.qt.io/post/512404</guid><dc:creator><![CDATA[schdaude]]></dc:creator><pubDate>Tue, 19 Feb 2019 08:23:16 GMT</pubDate></item><item><title><![CDATA[Reply to Rendering in QOpenGLWindow embedded in QMdiArea fails on Sun, 10 Feb 2019 21:09:55 GMT]]></title><description><![CDATA[<p dir="auto">Then there might be a bug with the Debian version... Especially since the same version downloaded through the installer does work correctly.</p>
]]></description><link>https://forum.qt.io/post/510682</link><guid isPermaLink="true">https://forum.qt.io/post/510682</guid><dc:creator><![CDATA[SGaist]]></dc:creator><pubDate>Sun, 10 Feb 2019 21:09:55 GMT</pubDate></item><item><title><![CDATA[Reply to Rendering in QOpenGLWindow embedded in QMdiArea fails on Thu, 31 Jan 2019 23:03:12 GMT]]></title><description><![CDATA[<p dir="auto">Interesting indeed ;)<br />
Yes, KWin is used in both cases.<br />
It's Debian 9.6. Rather fresh install coming with KDE (and now additionally GNOME for the described "digging")</p>
]]></description><link>https://forum.qt.io/post/508750</link><guid isPermaLink="true">https://forum.qt.io/post/508750</guid><dc:creator><![CDATA[schdaude]]></dc:creator><pubDate>Thu, 31 Jan 2019 23:03:12 GMT</pubDate></item><item><title><![CDATA[Reply to Rendering in QOpenGLWindow embedded in QMdiArea fails on Wed, 30 Jan 2019 21:57:25 GMT]]></title><description><![CDATA[<p dir="auto">Interesting...</p>
<p dir="auto">Is KWin used in both cases ?<br />
What Linux flavour are you running ?</p>
]]></description><link>https://forum.qt.io/post/508451</link><guid isPermaLink="true">https://forum.qt.io/post/508451</guid><dc:creator><![CDATA[SGaist]]></dc:creator><pubDate>Wed, 30 Jan 2019 21:57:25 GMT</pubDate></item><item><title><![CDATA[Reply to Rendering in QOpenGLWindow embedded in QMdiArea fails on Wed, 30 Jan 2019 10:38:27 GMT]]></title><description><![CDATA[<p dir="auto">Exactly. Same binary, just ran in GNOME instead KDE. In fact, further<br />
digging revealed that I don't even need to go that far. The<br />
"QOpenGLWindowInQMdiAreaMode" also works in KDE with Qt from the system.<br />
I just need to switch the widget style of the whole KDE desktop settings<br />
(e.g. from "Breeze" to "Fusion").</p>
<p dir="auto">Further observations in malfunctioning case:<br />
The subwindow is not only not rendered, but the decorators (maximize etc.) in<br />
the titlebar are not reactive: It just adapts the size of the main window but<br />
no way to minimize/maximize/close the subwindow. Maybe some initialization issue.<br />
The interesting point is that I don't observe that behaviour in<br />
"QOpenGLWidgetInQMdiAreaMode".</p>
<p dir="auto">Following Debug output might be relevant (Same binary, linked and compiled<br />
against Qt system default, define statement is "QOpenGLWindowInQMdiAreaMode"):</p>
<p dir="auto">"Breeze" widget style in KDE (has the described problematic behaviour):</p>
<pre><code>schdaude@schdaudoputer:~/workspace/gl_bug_report$ ./gl_bug_report                                                                    
Create widget using QOpenGLWidget as subwindow in QMdiArea                                                                           
Rendering fails on my machine                                                                                                        
Enter initializeGL                                                                                                                   
Enter resizeGL                                                                                                                       
Enter paintGL
</code></pre>
<p dir="auto">"Fusion" Widget style in KDE (fantastic triangle):</p>
<pre><code>schdaude@schdaudoputer:~/workspace/gl_bug_report$ ./gl_bug_report 
Create widget using QOpenGLWidget as subwindow in QMdiArea
Rendering fails on my machine
Enter initializeGL
Enter resizeGL
Enter paintGL
Enter paintGL
</code></pre>
<p dir="auto">There's one more call to paintGL in the latter.</p>
<p dir="auto">In the second round I increased the debug output from the QT side using<br />
"export QT_LOGGING_RULES="*.debug=true""</p>
<p dir="auto">"Breeze" widget style in KDE (has the described problematic behaviour):</p>
<pre><code>Lots of stuff
...
Enter initializeGL
Enter resizeGL
Enter paintGL
qt.widgets.gestures: QGestureManager:Recognizer: ignored the event:  QPanGesture(state=NoGesture,lastOffset=0,0QPointF(0,0),offset=0,0,acceleration=0,delta=0,0) QResizeEvent(1280, 800)
qt.widgets.gestures: QGestureManager:Recognizer: ignored the event:  QPanGesture(state=NoGesture,lastOffset=0,0QPointF(0,0),offset=0,0,acceleration=0,delta=0,0) QExposeEvent(QRegion(0,0 1280x800))
qt.widgets.gestures: QGestureManager:Recognizer: ignored the event:  QPanGesture(state=NoGesture,lastOffset=0,0QPointF(0,0),offset=0,0,acceleration=0,delta=0,0) QResizeEvent(1280, 800)
qt.widgets.gestures: QGestureManager:Recognizer: ignored the event:  QPanGesture(state=NoGesture,lastOffset=0,0QPointF(0,0),offset=0,0,acceleration=0,delta=0,0) QExposeEvent(QRegion(0,0 1280x800))
qt.widgets.gestures: QGestureManager:Recognizer: ignored the event:  QPanGesture(state=NoGesture,lastOffset=0,0QPointF(0,0),offset=0,0,acceleration=0,delta=0,0) QEvent(WindowActivate, 0x7ffcfc7e0760)
qt.widgets.gestures: QGestureManager:Recognizer: ignored the event:  QPanGesture(state=NoGesture,lastOffset=0,0QPointF(0,0),offset=0,0,acceleration=0,delta=0,0) QEvent(WindowActivate, 0x7ffcfc7e0760)
qt.widgets.gestures: QGestureManager:Recognizer: ignored the event:  QPanGesture(state=NoGesture,lastOffset=0,0QPointF(0,0),offset=0,0,acceleration=0,delta=0,0) QEvent(WindowActivate, 0x7ffcfc7e0760)
qt.widgets.gestures: QGestureManager:Recognizer: ignored the event:  QPanGesture(state=NoGesture,lastOffset=0,0QPointF(0,0),offset=0,0,acceleration=0,delta=0,0) QEvent(WindowActivate, 0x7ffcfc7e0760)
qt.widgets.gestures: QGestureManager:Recognizer: ignored the event:  QPanGesture(state=NoGesture,lastOffset=0,0QPointF(0,0),offset=0,0,acceleration=0,delta=0,0) QFocusEvent(FocusIn, ActiveWindowFocusReason)
qt.widgets.gestures: QGestureManager:Recognizer: ignored the event:  QPanGesture(state=NoGesture,lastOffset=0,0QPointF(0,0),offset=0,0,acceleration=0,delta=0,0) QInputMethodQueryEvent(queries=0x101, {})
qt.widgets.gestures: QGestureManager:Recognizer: ignored the event:  QPanGesture(state=NoGesture,lastOffset=0,0QPointF(0,0),offset=0,0,acceleration=0,delta=0,0) QInputMethodQueryEvent(queries=0x101, {})
qt.widgets.gestures: QGestureManager:Recognizer: ignored the event:  QPanGesture(state=NoGesture,lastOffset=0,0QPointF(0,0),offset=0,0,acceleration=0,delta=0,0) QFocusEvent(FocusAboutToChange, ActiveWindowFocusReason)
qt.widgets.gestures: QGestureManager:Recognizer: ignored the event:  QPanGesture(state=NoGesture,lastOffset=0,0QPointF(0,0),offset=0,0,acceleration=0,delta=0,0) QEvent(WindowDeactivate, 0x7ffcfc7e03b0)
...
Lots of more stuff
...
</code></pre>
<p dir="auto">"Fusion" widget style in KDE (fantastic triangle):</p>
<pre><code>...
Lots of stuff
...
Enter initializeGL
Enter resizeGL
Enter paintGL
qt.widgets.gestures: QGestureManager:Recognizer: ignored the event:  QPanGesture(state=NoGesture,lastOffset=0,0QPointF(0,0),offset=0,0,acceleration=0,delta=0,0) QExposeEvent(QRegion(size=8, bounds=(0,0 1280x5) - [(0,0 5x1), (1275,0 5x1), (0,1 3x1), (1277,1 3x1), (0,2 2x1), (1278,2 2x1), (0,3 1x2), (1279,3 1x2)]))
qt.widgets.gestures: QGestureManager:Recognizer: ignored the event:  QPanGesture(state=NoGesture,lastOffset=0,0QPointF(0,0),offset=0,0,acceleration=0,delta=0,0) QEvent(WindowActivate, 0x7ffef19f8080)
qt.widgets.gestures: QGestureManager:Recognizer: ignored the event:  QPanGesture(state=NoGesture,lastOffset=0,0QPointF(0,0),offset=0,0,acceleration=0,delta=0,0) QEvent(WindowActivate, 0x7ffef19f8080)
qt.widgets.gestures: QGestureManager:Recognizer: ignored the event:  QPanGesture(state=NoGesture,lastOffset=0,0QPointF(0,0),offset=0,0,acceleration=0,delta=0,0) QEvent(WindowActivate, 0x7ffef19f8080)
qt.widgets.gestures: QGestureManager:Recognizer: ignored the event:  QPanGesture(state=NoGesture,lastOffset=0,0QPointF(0,0),offset=0,0,acceleration=0,delta=0,0) QFocusEvent(FocusIn, ActiveWindowFocusReason)
qt.widgets.gestures: QGestureManager:Recognizer: ignored the event:  QPanGesture(state=NoGesture,lastOffset=0,0QPointF(0,0),offset=0,0,acceleration=0,delta=0,0) QInputMethodQueryEvent(queries=0x101, {})
qt.widgets.gestures: QGestureManager:Recognizer: ignored the event:  QPanGesture(state=NoGesture,lastOffset=0,0QPointF(0,0),offset=0,0,acceleration=0,delta=0,0) QInputMethodQueryEvent(queries=0x101, {})
qt.widgets.gestures: QGestureManager:Recognizer: ignored the event:  QPanGesture(state=NoGesture,lastOffset=0,0QPointF(0,0),offset=0,0,acceleration=0,delta=0,0) QExposeEvent(QRegion(size=8, bounds=(0,0 1280x800) - [(5,0 1270x1), (3,1 1274x1), (2,2 1276x1), (1,3 1278x2), (0,5 1280x19), (0,24 4x772), (1276,24 4x772), (0,796 1280x4)]))
qt.widgets.gestures: QGestureManager:Recognizer: ignored the event:  QPanGesture(state=NoGesture,lastOffset=0,0QPointF(0,0),offset=0,0,acceleration=0,delta=0,0) QExposeEvent(QRegion(size=2, bounds=(0,0 1272x772) - [(0,0 1272x24), (0,24 4x748)]))
Enter paintGL
qt.widgets.gestures: QGestureManager:Recognizer: ignored the event:  QPanGesture(state=NoGesture,lastOffset=0,0QPointF(0,0),offset=0,0,acceleration=0,delta=0,0) QFocusEvent(FocusAboutToChange, ActiveWindowFocusReason)
qt.widgets.gestures: QGestureManager:Recognizer: ignored the event:  QPanGesture(state=NoGesture,lastOffset=0,0QPointF(0,0),offset=0,0,acceleration=0,delta=0,0) QEvent(WindowDeactivate, 0x7ffef19f7cd0)
...
Lots of more stuff
...
</code></pre>
<p dir="auto">The QExposeEvents clearly differ and theres the additional call to paintGL.</p>
<p dir="auto">=&gt; local setup problem that gets triggered by some subtle difference in how the<br />
QMdiSubwindow is created?</p>
]]></description><link>https://forum.qt.io/post/508292</link><guid isPermaLink="true">https://forum.qt.io/post/508292</guid><dc:creator><![CDATA[schdaude]]></dc:creator><pubDate>Wed, 30 Jan 2019 10:38:27 GMT</pubDate></item><item><title><![CDATA[Reply to Rendering in QOpenGLWindow embedded in QMdiArea fails on Tue, 29 Jan 2019 17:12:26 GMT]]></title><description><![CDATA[<p dir="auto">Since you switched desktop, different window manager ?</p>
]]></description><link>https://forum.qt.io/post/508101</link><guid isPermaLink="true">https://forum.qt.io/post/508101</guid><dc:creator><![CDATA[SGaist]]></dc:creator><pubDate>Tue, 29 Jan 2019 17:12:26 GMT</pubDate></item><item><title><![CDATA[Reply to Rendering in QOpenGLWindow embedded in QMdiArea fails on Tue, 29 Jan 2019 14:31:47 GMT]]></title><description><![CDATA[<p dir="auto">Hey,</p>
<p dir="auto">Thanks, I fetched Qt 5.12 and indeed, I got the expected behaviour for all four<br />
modes (red triangle on a black background).<br />
However, I also fetched 5.7.1 (same version as the system default) and it<br />
also worked. Puzzling...</p>
<p dir="auto">So it's not an issue with the version but rather with the local setup.</p>
<p dir="auto">I even found another way to make things work:<br />
compile with system default but switch from KDE to GNOME...<br />
Even more puzzled... I need to further dig into it. I'll leave this thread open<br />
for one or two more days, maybe somebody has a comment on that. If not, I'll resolve<br />
as this seems to be not an issue with QT itself.</p>
<p dir="auto">Thanks again,<br />
Gabriel</p>
]]></description><link>https://forum.qt.io/post/508079</link><guid isPermaLink="true">https://forum.qt.io/post/508079</guid><dc:creator><![CDATA[schdaude]]></dc:creator><pubDate>Tue, 29 Jan 2019 14:31:47 GMT</pubDate></item><item><title><![CDATA[Reply to Rendering in QOpenGLWindow embedded in QMdiArea fails on Mon, 28 Jan 2019 22:20:28 GMT]]></title><description><![CDATA[<p dir="auto">Hi and welcome to devnet,</p>
<p dir="auto">The first thing I would try is to build and run your application with a more recent Qt version. The current version (and LTS) is 5.12.0.</p>
]]></description><link>https://forum.qt.io/post/507891</link><guid isPermaLink="true">https://forum.qt.io/post/507891</guid><dc:creator><![CDATA[SGaist]]></dc:creator><pubDate>Mon, 28 Jan 2019 22:20:28 GMT</pubDate></item></channel></rss>