# How to block the user selection of a node in a qMRMLNodeComboBox?

**URL:** https://discourse.slicer.org/t/how-to-block-the-user-selection-of-a-node-in-a-qmrmlnodecombobox/11582
**Category:** Support
**Created:** [May 16, 2020, 10:38pm UTC](https://discourse.slicer.org/t/how-to-block-the-user-selection-of-a-node-in-a-qmrmlnodecombobox/11582 "2020-05-16T22:38:29Z")
**Posts on this page:** 5
**Page:** 1

<div class="post-metadata">

### Author: ![xlucox](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/xlucox/32/6381_2.png) [@xlucox](https://discourse.slicer.org/u/xlucox)
#### Post date: [May 16, 2020, 10:38pm UTC](https://discourse.slicer.org/t/how-to-block-the-user-selection-of-a-node-in-a-qmrmlnodecombobox/11582/1 "2020-05-16T22:38:29Z")

</div>

Hello !!!

I’m trying to prevent the user to select a node in a qMRMLNodeComboBox. I think it should be an object within this class to block the selection of nodes.

I would appreciate if someone can help me.

Thank you very much.

---

<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: [May 17, 2020, 2:34am UTC](https://discourse.slicer.org/t/how-to-block-the-user-selection-of-a-node-in-a-qmrmlnodecombobox/11582/2 "2020-05-17T02:34:12Z")

</div>

You can filter what MRML nodes are displayed by calling [addAtribute](https://apidocs.slicer.org/master/classqMRMLNodeComboBox.html#a056b54be78c6053b6fd21d51b2b1d045). You can show/hide nodes that have certain attribute value.

---

<div class="post-metadata">

### Author: ![Alex\_Vergara](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/alex_vergara/32/15205_2.png) [@Alex\_Vergara](https://discourse.slicer.org/u/Alex_Vergara)
#### Post date: [August 24, 2020, 4:07pm UTC](https://discourse.slicer.org/t/how-to-block-the-user-selection-of-a-node-in-a-qmrmlnodecombobox/11582/3 "2020-08-24T16:07:50Z")

</div>

> [@lassoan](#):
>
> You can show/hide nodes that have certain attribute value.

Are there any example of this? I can’t manage to do this and I can’t find any use case that implements this.

---

<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 24, 2020, 4:14pm UTC](https://discourse.slicer.org/t/how-to-block-the-user-selection-of-a-node-in-a-qmrmlnodecombobox/11582/4 "2020-08-24T16:14:22Z")

</div>

You need to set an attribute value on MRML nodes that you want to show. Nodes that do not have this attribute set or the value does not match will not show up in the node selector.

You can use tests in Slicer core as examples: [https://github.com/Slicer/Slicer/search?q=addattribute&unscoped\_q=addattribute](https://github.com/Slicer/Slicer/search?q=addattribute&unscoped_q=addattribute)

Let us know if you have any suggestions how to improve [documentation](http://apidocs.slicer.org/master/classqMRMLNodeComboBox.html#a056b54be78c6053b6fd21d51b2b1d045) to make this more clear.

---

<div class="post-metadata">

### Author: ![Alex\_Vergara](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/alex_vergara/32/15205_2.png) [@Alex\_Vergara](https://discourse.slicer.org/u/Alex_Vergara)
#### Post date: [August 24, 2020, 4:17pm UTC](https://discourse.slicer.org/t/how-to-block-the-user-selection-of-a-node-in-a-qmrmlnodecombobox/11582/5 "2020-08-24T16:17:05Z")

</div>

Ah, is an MRML attribute! I was using a shnode attribute. Now it works, thanks!

```auto
        self.Image2 = slicer.qMRMLNodeComboBox()
        self.Image2.nodeTypes = ["vtkMRMLScalarVolumeNode"]
        self.Image2.addAttribute("vtkMRMLScalarVolumeNode", "DICOM.Modality", "RTDOSE")

```
