How to get the eye visibility checkbox widget in my module

I like the checkboxes that are used for showing and hiding.For example the one in the Volume Rendering module or to show/hide segments in the segment editor.

I know how to add an ordinary checkbox widget in my module using Python.

But how to make it into this eye-icon like checkbox?

You need to set the icons

image

Sorry, how do I actually set the icon? It looks like I need to select it from a file or resource, but I’m not sure what’s the easiest way to access that.

You start Qt Designer as described in the documentation. Then you click on the little arrow next to the icon (see screenshot above), then select Choose Resource.... You can then import the resource file path\to\Slicer\Libs\MRML\Widgets\Resources\qMRMLWidgets.qrc. You’ll then see the icons in the resource list.

I am trying to add the resource file, but I am unable to navigate to it or add that path. I am also unable to find the file on my Mac within the Slicer application.

It might be simpler to set the icon in the sou Ce code as it is done here: