# Customize error of qMRMLSliceControllerWidget

**URL:** https://discourse.slicer.org/t/customize-error-of-qmrmlslicecontrollerwidget/35331
**Category:** Development
**Created:** [April 7, 2024, 9:56am UTC](https://discourse.slicer.org/t/customize-error-of-qmrmlslicecontrollerwidget/35331 "2024-04-07T09:56:50Z")
**Posts on this page:** 7
**Page:** 1

<div class="post-metadata">

### Author: ![park](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/park/32/5717_2.png) [@park](https://discourse.slicer.org/u/park)
#### Post date: [April 7, 2024, 9:56am UTC](https://discourse.slicer.org/t/customize-error-of-qmrmlslicecontrollerwidget/35331/1 "2024-04-07T09:56:50Z")

</div>

Hi all,

I would like to customize of qMRMLSliceControllerWidget

My code is like this (there is no error), but it is not work well.  
Especially, the QLabel is not change and the maximize Button is not hide

Can I get a solution for this?

```auto
for viewColor in ["Red", "Green", "Yellow"]:
  widgets2D = layoutManager.sliceWidget(viewColor).findChild("qMRMLSliceControllerWidget")
      
  sliderWidget = widgets2D.findChild("qMRMLSliderWidget")
  sliderWidget.setVisible(False)

  buttons2D = widgets2D.findChildren('QToolButton')

  for button in buttons2D:
    button.setVisible(False)

  viewLabel = widgets2D.findChild("QLabel", "ViewLabel")

    
  if viewColor == "Red":
    viewLabel.setText("Axial")  

  if viewColor == "Green":
    viewLabel.setText("Coronal")

  if viewColor == "Yellow":
    viewLabel.setText("Saggital")

  font = qt.QFont()
  font.setPointSize(12)
  font.setBold(True)
  viewLabel.setFont(font)

  viewLabel.setAlignment(qt.Qt.AlignLeft)

```

---

<div class="post-metadata">

### Author: ![qiqi5210](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/qiqi5210/32/15920_2.png) [@qiqi5210](https://discourse.slicer.org/u/qiqi5210)
#### Post date: [April 7, 2024, 12:58pm UTC](https://discourse.slicer.org/t/customize-error-of-qmrmlslicecontrollerwidget/35331/2 "2024-04-07T12:58:41Z")

</div>

```auto
layoutManager=slicer.app.layoutManager()
for viewColor in ["Red", "Green", "Yellow"]:
  widgets2D = layoutManager.sliceWidget(viewColor).findChild("qMRMLSliceControllerWidget")
      
  sliderWidget = widgets2D.findChild("qMRMLSliderWidget")
  sliderWidget.setVisible(False)

  buttons2D=slicer.util.findChild(widgets2D, 'MaximizeViewButton')

  buttons2D.hide()

```

---

<div class="post-metadata">

### Author: ![park](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/park/32/5717_2.png) [@park](https://discourse.slicer.org/u/park)
#### Post date: [April 8, 2024, 7:43am UTC](https://discourse.slicer.org/t/customize-error-of-qmrmlslicecontrollerwidget/35331/3 "2024-04-08T07:43:40Z")

</div>

Using this code, it disappears like in the video and then reappears.

```auto
layoutManager = slicer.app.layoutManager()
twoDwidget = layoutManager.sliceWidget("Red")
twoDwidgetBar = twoDwidget.findChild("qMRMLSliceControllerWidget")
button = twoDwidgetBar.findChild("QToolButton", "MaximizeViewButton")
button.hide()

```

---

<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: [April 8, 2024, 5:19pm UTC](https://discourse.slicer.org/t/customize-error-of-qmrmlslicecontrollerwidget/35331/4 "2024-04-08T17:19:52Z")

</div>

Maximize/restore button state is managed by the widget, so you won’t be able to permanently change visibility by low-level under-the-hood manipulations. Instead, you can hide the entire qMRMLViewControllerBar or implement a flag that allows disabling of the maximize/restore feature.

---

<div class="post-metadata">

### Author: ![park](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/park/32/5717_2.png) [@park](https://discourse.slicer.org/u/park)
#### Post date: [April 9, 2024, 3:53am UTC](https://discourse.slicer.org/t/customize-error-of-qmrmlslicecontrollerwidget/35331/5 "2024-04-09T03:53:39Z")

</div>

I got a soultion about it

```auto
for controllerBar in slicer.util.mainWindow().findChildren("qMRMLViewControllerBar"):
    controllerBar.showMaximizeViewButton = 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: [April 9, 2024, 4:26pm UTC](https://discourse.slicer.org/t/customize-error-of-qmrmlslicecontrollerwidget/35331/6 "2024-04-09T16:26:39Z")

</div>

You may still be able to maximize the view by using the right-click menu or double-click on the view. That may show the maximize button again.

---

<div class="post-metadata">

### Author: ![park](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/park/32/5717_2.png) [@park](https://discourse.slicer.org/u/park)
#### Post date: [April 12, 2024, 2:00am UTC](https://discourse.slicer.org/t/customize-error-of-qmrmlslicecontrollerwidget/35331/7 "2024-04-12T02:00:14Z")

</div>

I think it works well. It dose not appear again.
