Two different layoutWidget

Hi,
I’m developing a custom interface with slicer for one of my projects, and i’m facing a “simple” problem.

I want in the same QWidget two different layoutWidget with two different layout manager, but when I create the objects it seems that they are the same layout manager for both widgets. Is it possible to have separate layout manager?

Following a simple example to show you what is the problem !

import qt import __main__

mainWidget = qt.QWidget()
mainWidget.objectName = “TestWidget”
vBoxLayout = qt.QVBoxLayout()
mainWidget.setLayout(vBoxLayout)

lm = slicer.qSlicerLayoutManager()
lm.setMRMLScene(slicer.mrmlScene)
lm.setLayout(slicer.vtkMRMLLayoutNode.SlicerLayoutOneUpRedSliceView)
lw = slicer.qMRMLLayoutWidget()
lw.setLayoutManager(lm)

lw2 = slicer.qMRMLLayoutWidget()
lm2 = slicer.qSlicerLayoutManager()
lm2.setMRMLScene(slicer.mrmlScene)
lm2.setLayout(slicer.vtkMRMLLayoutNode.SlicerLayoutOneUp3DView)
lw2.setLayoutManager(lm2)

vBoxLayout.addWidget(lw)
vBoxLayout.addWidget(lw2)
mainWidget.show()

I hope you can help me, any suggestion would be appreciate !

There can be only one layout manager in the application and it displays all views within a single layout widget. If you want to add more views, detached from the layout widget, then you have to add them outside the layout and manage them yourself, as shown in examples in script repository.

We’ve been discussing with @sunderlandkyl about the possibility of improving the layout manager with multi-monitor layouts. The layout manager would be able create additional widgets (maybe in a dockable window), which would be shown on second display (or third, fourth, …). Would this address your needs?

Thanks for the quick reply!
Yes, i started to do every single view outside , but I was hoping there was an easier solution with the layout manager. I’ll continue with that !

I’m interested on layout manager improvement, maybe that could help me / us !

Best regards,
Andrea

You can create your GUI in Qt designer and load the generated .ui file. That way the GUI design is quite effortless, even if you have many widgets.

Ye, true! I’m doing everything with qt designer.

When I saw that there was the possibility of creating everything from the designer, it has speeded me up a lot.
I have experience in qt and pythonqt as well. :slight_smile:

I will do a custom widget and a class that handle all the views and i will share it here

Thanks!