QOpenGLWidget inside a QDockWidget not updated when QDockWidget::setFloating(true)
Hello Qt wizards,
I've been pulling my hair one this one for a few months now, expecting that Qt 5.8 would solve this issue but unfortunately, it is not the case.
So basically, rendering a QOpenGLWidget placed in a QDockWidget works beautifully when docked but as soon as it is floating, the QOpenGLWidget hangs on the last rendered frame. Strangely enough, when hovering the cursor over the children widgets (of the same dock), I get new frames rendered.
Does anyone ever encounter this behavior and/or have any insight on how to fix this?
Thank you,
Re: QOpenGLWidget inside a QDockWidget not updated when QDockWidget::setFloating(true
That could be a bug.
Have you tried locating similar reports in the Qt bug tracker?
Cheers,
_
Re: QOpenGLWidget inside a QDockWidget not updated when QDockWidget::setFloating(true
Hello Anda,
Thank you for your suggestions,
It appears that the docking/un-docking has several issues. The closest ones I could find:
An easy way to workaround the problem is to app.setAttribute(Qt::AA_DontCreateNativeWidgetSibl ings) right after instantiating the QApplication. This should ensure the underlying QWindow hierarchy remains minimal, limiting any kind of side effects.
https://bugreports.qt.io/browse/QTBUG-31048
QDockWidget when floating with a central QGLWidget stops redrawing or permanently "burns" into the screen
https://bugreports.qt.io/browse/QTBUG-36967
It mentioned QApplication::setAttribute(Qt::AA_NativeWindows) but it doesn't help in my case.
Which leads to this:
QDockWidget and QToolBar set the Qt::BypassWindowManagerHint window flag
when unplugging and clear it in the endDrag() methods. This does not have
any effect since the attribute is not taken into account in
QXcbWindow::setWindowFlags(). Change the method to always set the attributes,
which should also make it possible to set/clear Qt::WindowTransparentForInput.
So again, not very helpful here.
Also:
https://bugreports.qt.io/browse/QTBU...%20floating%22
so it seems to be a known bug but nothing is very helpful for fixing it so far, at least on Windows 8.1.
I'm still digging,
Re: QOpenGLWidget inside a QDockWidget not updated when QDockWidget::setFloating(true
I accidently found a solution,
It looks like adding the code snippet below anywhere in my code fixes the problem:
Code:
#include <QWebEngineView>
class QT_WebView : public QWebEngineView
{
Q_OBJECT
public:
QT_WebView
(QWidget *in_parent
= NULL) : QWebEngineView
(in_parent
) {}};
No need to mentioned that this is as hocus pocus as it gets and the hack is quite a huge dependency to add in a project. I'm still digging and hopping to find an more elegant fix.
It seems the bug has to do with OpenGL context sharing and I try quite a few combinations without any good outcome so far.
Re: QOpenGLWidget inside a QDockWidget not updated when QDockWidget::setFloating(true
Oh, man, this is complete voodoo. You don't even need an instance of the class, you just need to define it? What if you don't define the class, but just declare an instance of QWebEngineView in main() but never show() it? Or simply include the QWebEngineView header file in main()?
Re: QOpenGLWidget inside a QDockWidget not updated when QDockWidget::setFloating(true
This is good voodoo stuff indeed!
Quote:
You don't even need an instance of the class, you just need to define it?
That is correct.
Quote:
What if you don't define the class, but just declare an instance of QWebEngineView in main() but never show() it?
Declaring an instance of QWebEngineView to the main() do work:
QWebEngineView l_QWebEngineView;
Quote:
Or simply include the QWebEngineView header file in main()?
Good call but nope.