# Update slice views from qMRMLNodeComboBox

**URL:** <https://discourse.slicer.org/t/update-slice-views-from-qmrmlnodecombobox/12383>\
**Category:** Support\
**Created:** [July 5, 2020, 3:20pm UTC](https://discourse.slicer.org/t/update-slice-views-from-qmrmlnodecombobox/12383 "2020-07-05T15:20:09Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![sogo](https://avatars.discourse-cdn.com/v4/letter/s/779978/32.png) [@sogo](https://discourse.slicer.org/u/sogo)\
**Post date:** [July 5, 2020, 3:20pm UTC](https://discourse.slicer.org/t/update-slice-views-from-qmrmlnodecombobox/12383/1 "2020-07-05T15:20:09Z")

</div>

Hi,  
My question is, is there a way to display slice views from currently selected Volume in qMRMLNodeComboBox. I have a small loadable module c++ script in which I’m using qMRMLNodeComboBox copied from “volumes” module. The combobox does get populated when adding volumes from “add data” script. I would like the slice views display to get updated with currently selected Volume in combo box. Right now I have to go to “Data” module and click on “show/hide branch node”. Thanks

---

<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 6, 2020, 5:20am UTC](https://discourse.slicer.org/t/update-slice-views-from-qmrmlnodecombobox/12383/2 "2020-07-06T05:20:00Z")

</div>

See several solutions in the script repository: [https://www.slicer.org/wiki/Documentation/Nightly/ScriptRepository#Iterate\_over\_current\_visible\_slice\_views.2C\_and\_set\_foreground\_and\_background\_images](https://www.slicer.org/wiki/Documentation/Nightly/ScriptRepository#Iterate_over_current_visible_slice_views.2C_and_set_foreground_and_background_images)

---

<div class="post-metadata">

**Author:** ![sogo](https://avatars.discourse-cdn.com/v4/letter/s/779978/32.png) [@sogo](https://discourse.slicer.org/u/sogo)\
**Post date:** [July 7, 2020, 7:07am UTC](https://discourse.slicer.org/t/update-slice-views-from-qmrmlnodecombobox/12383/3 "2020-07-07T07:07:04Z")

</div>

Hi Lassoan,  
Thanks for pointing out, at first I wasn’t if sure if there is c++ based alternative for these scripts but I have figured it out. So I’m using push button to get the volumeNode and displaying it in this way. This is called after we select the volume from qMRMLComboBox and click on push button

```
qSlicerLayoutManager* layoutManager = getLayout();
  if (layoutManager != NULL) {   
  vtkMRMLVolumeNode* currentVolume = vtkMRMLVolumeNode::SafeDownCast(d->ActiveVolumeNodeSelector->currentNode());
  std::array<std::string, 3> color = {"Red", "Yellow", "Green"};
  for(const auto& color : color) {  
  QString Color=QString::fromStdString(color);
  vtkMRMLSliceCompositeNode* compositeNode = layoutManager->sliceWidget(Color)->sliceLogic()->GetSliceCompositeNode();
  compositeNode->SetBackgroundVolumeID(currentVolume->GetID());
  compositeNode->SetForegroundVolumeID(currentVolume->GetID());
  
  }
  layoutManager->resetSliceViews();

```

Thanks for your help, appreciate it. Closing this thread
