From 9bb66da3987bd44f24a61e9970c8fa8ef6ecf417 Mon Sep 17 00:00:00 2001 From: Julien Finet Date: Fri, 30 Sep 2011 14:51:33 -0400 Subject: [PATCH] Fix QVTKWidget refresh on resize problem on Windows When resizing a toplevel QVTKWidget, only the newly exposed part is refreshed, not the entire viewport. Qt::WA_PaintOnScreen is only supported on X11: http://doc.qt.nokia.com/4.7/qt.html#WidgetAttribute-enum For all purpose widgets, it is ok to leave the flag Qt::WA_PaintOnScreen for other platforms, because the flag is ignored. See QWidget::setAttribute(), there is a special to ignore the flag on Windows. However, QVTKWidget uses a custom QPaintEngine, so the hack done in QWidget::paintEngine() on Windows is not applied and doesn't ignore the flag then: Here is an extract from qwidget_win.cpp (in QWidget::paintEngine) // We set this bit which is checked in setAttribute for // Qt::WA_PaintOnScreen. We do this to allow these two scenarios: // // 1. Users accidentally set Qt::WA_PaintOnScreen on X and port to // windows which would mean suddenly their widgets stop working. // // 2. Users set paint on screen and subclass paintEngine() to // return 0, in which case we have a "hole" in the backingstore // allowing use of GDI or DirectX directly. // // 1 is WRONG, but to minimize silent failures, we have set this // bit to ignore the setAttribute call. 2. needs to be // supported because its our only means of embeddeding native // graphics stuff. const_cast(d_func())->noPaintOnScreen = 1; Please note that QVTKWidget2 (QGLWidget) sets the flag Qt::WA_PaintOnScreen all platforms. However, various hacks in Qt GUI (qwidget.cpp, qwidget_win.cpp, qbackingstore.cpp...) make QGLWidget works fine on Windows. Change-Id: Ia5d8256152885932ab500a761d619f673f43956f --- GUISupport/Qt/QVTKWidget.cxx | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/GUISupport/Qt/QVTKWidget.cxx b/GUISupport/Qt/QVTKWidget.cxx index 430f1f82c20..22b4903dde8 100644 --- a/GUISupport/Qt/QVTKWidget.cxx +++ b/GUISupport/Qt/QVTKWidget.cxx @@ -78,8 +78,10 @@ QVTKWidget::QVTKWidget(QWidget* p, Qt::WFlags f) this->UseTDx=false; // no background this->setAttribute(Qt::WA_NoBackground); - // no double buffering + // no double buffering (only supported by X11) +#ifdef Q_WS_X11 this->setAttribute(Qt::WA_PaintOnScreen); +#endif // default to strong focus this->setFocusPolicy(Qt::StrongFocus);