Skip to content

Commit

Permalink
Fix QVTKWidget refresh on resize problem on Windows
Browse files Browse the repository at this point in the history
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<QWidgetPrivate *>(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
  • Loading branch information
finetjul committed Oct 17, 2012
1 parent 8076ed6 commit 9bb66da
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion GUISupport/Qt/QVTKWidget.cxx
Expand Up @@ -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);
Expand Down

0 comments on commit 9bb66da

Please sign in to comment.