Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct
Graphics artifacts in X11 with OpenGL software rendering
Hannes Kroeger last edited by
I came across a weird problem and I'm currently a bit lost about how to find a workaround. Maybe someone here has a hint about how to proceed.
My project so far:
- a Qt-5 GUI (Qt 5.15) written in C++ for Linux (Ubuntu 20LTS) with several controls in the main window
- the application links an external library (OpenCASCADE CAD kernel, OCC) and embeds OCC'S OpenGL Viewer in a dedicated widget. The OCC viewer is embedded in a Qt Widget, which set the flags Qt::WA_NoSystemBackground and Qt::WA_PaintOnScreen and returns a nullptr paintEngine, so merely acts as a frame for the external viewer.
This works nicely in Linux without problems.
Now, I want to run the application in Windows-10's WSL system with a VcXsrc as X-Server and Mesa software rendering.
Actually this kind of works also. The OpenGL viewer shows its image without errors. But the other Qt controls (especially QTextEdit and QLineEdit type controls) all get deteriorated with black rectangle artifacts when the window is resized or redrawn.
When the OCC Viewer widget is removed, the artifacts are gone also.
Obviously there is kind of an interference between the external OpenGL widget and Qt.
I tried some other X-Servers for Windows (Xming, MobaXterm) but all showed the same problem. Interestingly, when I log into the Linux machine and direct the X output to the windows host, I also see the artifacts in the output of the Linux application).
As said, I'm looking for a workaround but I'm not sure where to look for the reason. How does Qt use OpenGL for a plain desktop application? Is there a way to revert to some kind of legacy drawing of the controls and widget contents?
Thanks for any hint.
gde23 last edited by
Two ideas what could help although its just a guess.
somewhere in your main() fuction.
Another idea that could help is, if there are any functions in your OpenGL widget that get called from outside and change opengl stuff to add
QOpenGLWidget::makeCurrent();at the begin of the function. However since your using the viewer from the OCCT library I guess you do not want to change anything in the lib.
Hannes Kroeger last edited by Hannes Kroeger
thanks for your comments!
I tried your first guess, but that did not change anything.
BTW, I'm no longer sure that the OpenGL viewer is actually causing the trouble. My impression is, that the flags of the container widget is causing issues.
I did a quick test and removed all the external calls to OCC so that just an empty widget with
setMouseTracking( true );
setBackgroundRole( QPalette::NoRole );
setAttribute( Qt::WA_NoSystemBackground );
setAttribute( Qt::WA_PaintOnScreen );
And: the problem is still there.
It's only disappearing, if I remove the WA_PaintOnScreen flag.
Unfortunately, if I re-enable all the OpenGL viewer stuff with WA_PaintOnScreen unset, the problem is there again...