Skip to content

Commit

Permalink
Qt5OpenGL: fix to make the 3d viewer fit into the mdi area after re-d…
Browse files Browse the repository at this point in the history
…ocking it
  • Loading branch information
wwmayer committed Mar 21, 2017
1 parent 727bfa2 commit b9934f0
Showing 1 changed file with 27 additions and 0 deletions.
27 changes: 27 additions & 0 deletions src/Gui/View3DInventor.cpp
Expand Up @@ -54,6 +54,11 @@
# include <Inventor/fields/SoSFColor.h>
#endif
# include <QStackedWidget>
#include <QtOpenGL.h>

#if defined(HAVE_QT5_OPENGL)
# include <QWindow>
#endif

#include <Base/Exception.h>
#include <Base/Console.h>
Expand Down Expand Up @@ -982,6 +987,21 @@ void View3DInventor::setCurrentViewMode(ViewMode newmode)
ViewMode oldmode = MDIView::currentViewMode();
if (oldmode == newmode)
return;

#if defined(HAVE_QT5_OPENGL)
if (newmode == Child) {
// Fix in two steps:
// The mdi view got a QWindow when it became a top-level widget and when resetting it to a child widget
// the QWindow must be deleted because it has an impact on resize events and may break the layout of
// mdi view inside the QMdiSubWindow.
// In the second step below the layout must be invalidated after it's again a child widget to make sure
// the mdi view fits into the QMdiSubWindow.
QWindow* winHandle = this->windowHandle();
if (winHandle)
winHandle->destroy();
}
#endif

MDIView::setCurrentViewMode(newmode);

// This widget becomes the focus proxy of the embedded GL widget if we leave
Expand Down Expand Up @@ -1009,6 +1029,13 @@ void View3DInventor::setCurrentViewMode(ViewMode newmode)
QList<QAction*> acts = this->actions();
for (QList<QAction*>::Iterator it = acts.begin(); it != acts.end(); ++it)
this->removeAction(*it);

#if defined(HAVE_QT5_OPENGL)
// Step two
QMdiSubWindow* mdi = qobject_cast<QMdiSubWindow*>(parentWidget());
if (mdi && mdi->layout())
mdi->layout()->invalidate();
#endif
}
}

Expand Down

0 comments on commit b9934f0

Please sign in to comment.