# Remove Interaction toolbar from QMRMLSliceWidget

**URL:** <https://discourse.slicer.org/t/remove-interaction-toolbar-from-qmrmlslicewidget/8011>\
**Category:** Development\
**Created:** [August 13, 2019, 6:54pm UTC](https://discourse.slicer.org/t/remove-interaction-toolbar-from-qmrmlslicewidget/8011 "2019-08-13T18:54:58Z")\
**Posts on this page:** 11\
**Page:** 1

<div class="post-metadata">

**Author:** ![burnhamd](https://avatars.discourse-cdn.com/v4/letter/b/5fc32e/32.png) [@burnhamd](https://discourse.slicer.org/u/burnhamd)\
**Post date:** [August 13, 2019, 6:54pm UTC](https://discourse.slicer.org/t/remove-interaction-toolbar-from-qmrmlslicewidget/8011/1 "2019-08-13T18:54:58Z")

</div>

I would like to remove the toolbar from the qMRMLSliceWidget for a cleaner UI for a project I am working on. Is there a way to do this on the widget or should I display the slice by another method.

For reference this is the toolbar I am referring to.

 ![Capture](https://us1.discourse-cdn.com/flex002/uploads/slicer/original/3X/d/7/d75dfba000ac634837e3080c484932183afc8c42.png)

---

<div class="post-metadata">

**Author:** ![pieper](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/pieper/32/8_2.png) [@pieper](https://discourse.slicer.org/u/pieper)\
**Post date:** [August 13, 2019, 7:28pm UTC](https://discourse.slicer.org/t/remove-interaction-toolbar-from-qmrmlslicewidget/8011/2 "2019-08-13T19:28:31Z")

</div>

AFAIK there’s no option exposed for that. It would be a bit of a hack (but not unprecedented) to use [findChild](https://doc.qt.io/qt-5/qobject.html#findChild) at the qt in python level to remove the pushpin widget so the popup would never appear.

---

<div class="post-metadata">

**Author:** ![burnhamd](https://avatars.discourse-cdn.com/v4/letter/b/5fc32e/32.png) [@burnhamd](https://discourse.slicer.org/u/burnhamd)\
**Post date:** [August 13, 2019, 8:17pm UTC](https://discourse.slicer.org/t/remove-interaction-toolbar-from-qmrmlslicewidget/8011/3 "2019-08-13T20:17:34Z")

</div>

Thats a good thought. I will try that.

---

<div class="post-metadata">

**Author:** ![burnhamd](https://avatars.discourse-cdn.com/v4/letter/b/5fc32e/32.png) [@burnhamd](https://discourse.slicer.org/u/burnhamd)\
**Post date:** [August 13, 2019, 8:46pm UTC](https://discourse.slicer.org/t/remove-interaction-toolbar-from-qmrmlslicewidget/8011/4 "2019-08-13T20:46:04Z")

</div>

Having trouble finding documentation on the children of QMRMLSliceWidget. Is there somewhere that outlines this? Or a way to get a list of all children? calling findChildren(’\*’) yielded empty result.

---

<div class="post-metadata">

**Author:** ![jcfr](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/jcfr/32/17825_2.png) [@jcfr](https://discourse.slicer.org/u/jcfr)\
**Post date:** [August 13, 2019, 9:05pm UTC](https://discourse.slicer.org/t/remove-interaction-toolbar-from-qmrmlslicewidget/8011/5 "2019-08-13T21:05:30Z")

</div>

You could also doing something like this:

```python
for viewName in ["Green", "Red", "Yellow"]:
  slicer.app.layoutManager().sliceWidget(viewName).sliceController().setVisible(False)

```

---

<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:** [August 14, 2019, 4:13am UTC](https://discourse.slicer.org/t/remove-interaction-toolbar-from-qmrmlslicewidget/8011/6 "2019-08-14T04:13:06Z")

</div>

You can also use `slicer.util.setViewControllersVisible(False)` in recent Preview Releases.

If you want to create a Slicer-based application with a customized look&feel then you’ll probably find this page useful: [https://www.slicer.org/wiki/Documentation/Nightly/Developers/Slicelets](https://www.slicer.org/wiki/Documentation/Nightly/Developers/Slicelets)

---

<div class="post-metadata">

**Author:** ![burnhamd](https://avatars.discourse-cdn.com/v4/letter/b/5fc32e/32.png) [@burnhamd](https://discourse.slicer.org/u/burnhamd)\
**Post date:** [August 14, 2019, 9:51pm UTC](https://discourse.slicer.org/t/remove-interaction-toolbar-from-qmrmlslicewidget/8011/7 "2019-08-14T21:51:22Z")

</div>

@Iassoan , I did look into the slicelet templates. I am following basically this approach, but currently building the UI a different way. Having everything for my module on the sidebar and having the layout always visible next to it doesnt work for my application.

I am currently building a guided screen which opens several screens that get some user input, then I display a custom display consisting of QMRMLSliceWidgets.

---

<div class="post-metadata">

**Author:** ![burnhamd](https://avatars.discourse-cdn.com/v4/letter/b/5fc32e/32.png) [@burnhamd](https://discourse.slicer.org/u/burnhamd)\
**Post date:** [August 20, 2019, 9:01pm UTC](https://discourse.slicer.org/t/remove-interaction-toolbar-from-qmrmlslicewidget/8011/8 "2019-08-20T21:01:34Z")

</div>

Continuing on this track, I want to add my own interaction widgets to the top of the slice view.

Im considering a few paths.

1. I create my own widget in c++ that is similar to the qMRMLSliceWidget  
2.I build essentially the same thing in python using qMRMLSliceView - so far I only get a slicer crash when in do a show of a sliceview  
3.I hide the toolbar and simply place my buttons above the qMRMLSliceWidget in my layout.

Any thoughts on these approaches? I think 3 is easiest, but doesnt allow me to embed some of the logic in the view itself, but I havent been able to get very far with option 2.

---

<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:** [August 21, 2019, 3:04am UTC](https://discourse.slicer.org/t/remove-interaction-toolbar-from-qmrmlslicewidget/8011/9 "2019-08-21T03:04:31Z")

</div>

You can customize widgets in the existing slice controller widgets any way you need: you can hide any built-in widget and add your own, as shown in the [examples in script repository](https://www.slicer.org/wiki/Documentation/Nightly/ScriptRepository#Customize_widgets_in_view_controller_bars).

---

<div class="post-metadata">

**Author:** ![burnhamd](https://avatars.discourse-cdn.com/v4/letter/b/5fc32e/32.png) [@burnhamd](https://discourse.slicer.org/u/burnhamd)\
**Post date:** [August 27, 2019, 2:14pm UTC](https://discourse.slicer.org/t/remove-interaction-toolbar-from-qmrmlslicewidget/8011/10 "2019-08-27T14:14:58Z")

</div>

Getting a layout issue when I remove the widgets using the method in the script repository. The slice view becomes very small and the 3D grows to cover most of the space.

 ![image](https://us1.discourse-cdn.com/flex002/uploads/slicer/original/3X/e/1/e1f9ba5ae93db72790eba124cfc5758c22de2e84.png)

Is this expected?

---

<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:** [August 27, 2019, 2:20pm UTC](https://discourse.slicer.org/t/remove-interaction-toolbar-from-qmrmlslicewidget/8011/11 "2019-08-27T14:20:24Z")

</div>

Yes, it works as expected. You must to set up size policies in your Qt widgets according to what you need. Setting up size policies is not simple but it is standard Qt matter - there is nothing Slicer specific about how Qt widgets are sized in Slicer. See documentation [here](https://doc.qt.io/qt-5/qsizepolicy.html).
