Hide/Show (Minimize/Maximize) vtkRenderer

Hello, I have this piece of code, which puts 4 vtkRenderers in 1 Window, which are separated (aka 4 screens in 1 window). And I wanted to make feature of Maximize/Minimizing each screen, and thats where I’ve stuck.

I thought that just setting all viewports to (0, 0, 0, 0) (and then set “maximized” viewport to (0, 0, 1, 1) and then just reverse viewports back to original values) would solve the problem, but setting viewports kinda behaves weirdly, other renderers just stop display their content after resizing viewports back to original.

Is this even a correct way of minimizing/maximizing screens, or there are far better ways?

renWin = vtkRenderWindow();
RendererArray = [None]*4;
for i in range(0,4):
    RendererArray[i] = vtkRenderer();
    renWin.AddRenderer(RendererArray[i]);

RendererArray[0].SetViewport(0, 0, 0.5, 0.5);
RendererArray[1].SetViewport(0.5, 0, 1, 0.5);
RendererArray[2].SetViewport(0, 0.5, 0.5, 1);
RendererArray[3].SetViewport(0.5, 0.5, 1, 1);
renWin.Render();

If you are using Qt then you can use the layout manager in CTK that supports this feature (see it in action in 3D Slicer here). If you don’t want to add CTK as a dependency then you can reimplement the feature yourself - the main idea is that each Qt widget shows only a single view, so it is very easy to show/hide/resize the views using standard Qt widget infrastructure.