PDA

View Full Version : QOpenGLWidget inside a QDockWidget not updated when QDockWidget::setFloating(true)



neosettler
25th January 2017, 05:59
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,

anda_skoa
25th January 2017, 10:03
That could be a bug.

Have you tried locating similar reports in the Qt bug tracker?

Cheers,
_

neosettler
25th January 2017, 16:43
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/QTBUG-14083?jql=text%20~%20%22QDockWidgets%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,

neosettler
11th March 2017, 22:41
I accidently found a solution,

It looks like adding the code snippet below anywhere in my code fixes the problem:


#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.

d_stranz
15th March 2017, 16:37
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()?

neosettler
17th March 2017, 00:20
This is good voodoo stuff indeed!


You don't even need an instance of the class, you just need to define it?
That is correct.


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;


Or simply include the QWebEngineView header file in main()?

Good call but nope.