# Segment Editor shortcurts does not work

**URL:** <https://discourse.slicer.org/t/segment-editor-shortcurts-does-not-work/35303>\
**Category:** Development\
**Created:** [April 5, 2024, 7:35am UTC](https://discourse.slicer.org/t/segment-editor-shortcurts-does-not-work/35303 "2024-04-05T07:35:53Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![SANTIAGO\_PENDON\_MING](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/santiago_pendon_ming/32/66060_2.png) [@SANTIAGO\_PENDON\_MING](https://discourse.slicer.org/u/SANTIAGO_PENDON_MING)\
**Post date:** [April 5, 2024, 7:35am UTC](https://discourse.slicer.org/t/segment-editor-shortcurts-does-not-work/35303/1 "2024-04-05T07:35:53Z")

</div>

Hi to everyone 🙂

Today I’m looking for the command to activate and deactivate the segment Editor shortcuts using Python code. The shortcuts sometimes works correctly and then, in the same conditions if I open again the segmentation they doesn’t work anymore.

Can I anybody explain me how this works, and if it’s possible to activate and deactivate it?

Thanks a lot.

---

<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 6, 2024, 3:17pm UTC](https://discourse.slicer.org/t/segment-editor-shortcurts-does-not-work/35303/2 "2024-04-06T15:17:25Z")

</div>

Management of shortcuts in Qt is quite complex and fragile. Most often shortcuts break when you are trying to assign a shortcut multiple times. Make sure that after calling `installKeyboardShortcuts` you always call `uninstallKeyboardShortcuts`.

---

<div class="post-metadata">

**Author:** ![Suhaim](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/suhaim/32/81421_2.png) [@Suhaim](https://discourse.slicer.org/u/Suhaim)\
**Post date:** [December 17, 2025, 6:53am UTC](https://discourse.slicer.org/t/segment-editor-shortcurts-does-not-work/35303/3 "2025-12-17T06:53:37Z")

</div>

> [@lassoan](#):
>
> Make sure that after calling `installKeyboardShortcuts` you always call `uninstallKeyboardShortcuts`.

Hi @lassoan, could you please elaborate what you meant here?

Like @SANTIAGO_PENDON_MING tried, I was also disabling the shortcut “Ctrl+Z” with custom logic using -

```auto
def disableShortcut(sequence: str):
    shortcut = qt.QShortcut(slicer.util.mainWindow())
    shortcut.setKey(qt.QKeySequence(sequence))
    shortcut.connect("activated()", lambda: None)

```

After disabling the shortcut once, if I restart the application with the calls to this function removed( therefore no more “Ctrl+z” shortcut override), I am not able to use the shortcut for the segment editor. Like @SANTIAGO_PENDON_MING mentioned, the shortcut doesn’t work anymore. Would you happen to know why?

Found this in another post as well :-

> [@Shortcuts and keys already assigned somewhere else?](https://discourse.slicer.org/t/shortcuts-and-keys-already-assigned-somewhere-else/26632/4):
>
> If you or someone else adds a shortcut with the same key sequence then effectively breaks all actions, as the shortcut will no longer emit `activated()` signal but `activatedAmbiguously()`.
> 
> Unfortunately, I don’t know an easy way to determine where each shortcut comes from where, other than search in the source code of all installed extensions for `shortcut`.
> 
> Extensions should not install any keyboard shortcut by default (without explicitly approved by the user). Also, if any shortcut is added then a meaningful `objectName` should be set, for example containing the name of the extension and module, to make it easier to detect and resolve conflicts by turning off irrelevant shortcuts.

So are you suggesting that I **should not disable “Ctrl+z“ based on custom logic**?
