# Two different layoutWidget

**URL:** https://discourse.slicer.org/t/two-different-layoutwidget/7567
**Category:** Development
**Created:** [July 14, 2019, 4:51pm UTC](https://discourse.slicer.org/t/two-different-layoutwidget/7567 "2019-07-14T16:51:18Z")
**Posts on this page:** 5
**Page:** 1

<div class="post-metadata">

### Author: ![AndreaRoberti](https://avatars.discourse-cdn.com/v4/letter/a/ecd19e/32.png) [@AndreaRoberti](https://discourse.slicer.org/u/AndreaRoberti)
#### Post date: [July 14, 2019, 4:51pm UTC](https://discourse.slicer.org/t/two-different-layoutwidget/7567/1 "2019-07-14T16:51:18Z")

</div>

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 !

---

<div class="post-metadata">

### Author: ![lassoan](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/lassoan/32/13_2.png) [@lassoan](https://discourse.slicer.org/u/lassoan)
#### Post date: [July 14, 2019, 6:20pm UTC](https://discourse.slicer.org/t/two-different-layoutwidget/7567/2 "2019-07-14T18:20:20Z")

</div>

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](https://www.slicer.org/wiki/Documentation/Nightly/ScriptRepository#Show_a_slice_view_outside_the_view_layout).

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?

---

<div class="post-metadata">

### Author: ![AndreaRoberti](https://avatars.discourse-cdn.com/v4/letter/a/ecd19e/32.png) [@AndreaRoberti](https://discourse.slicer.org/u/AndreaRoberti)
#### Post date: [July 14, 2019, 6:40pm UTC](https://discourse.slicer.org/t/two-different-layoutwidget/7567/3 "2019-07-14T18:40:18Z")

</div>

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

---

<div class="post-metadata">

### Author: ![lassoan](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/lassoan/32/13_2.png) [@lassoan](https://discourse.slicer.org/u/lassoan)
#### Post date: [July 14, 2019, 6:42pm UTC](https://discourse.slicer.org/t/two-different-layoutwidget/7567/4 "2019-07-14T18:42:23Z")

</div>

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.

---

<div class="post-metadata">

### Author: ![AndreaRoberti](https://avatars.discourse-cdn.com/v4/letter/a/ecd19e/32.png) [@AndreaRoberti](https://discourse.slicer.org/u/AndreaRoberti)
#### Post date: [July 14, 2019, 6:55pm UTC](https://discourse.slicer.org/t/two-different-layoutwidget/7567/5 "2019-07-14T18:55:39Z")

</div>

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. 🙂

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

Thanks!
