Disable Custom Context Menu items in PyQt

pyqt

Solution

To disable a menu item, just disable the `QAction`

action.setEnabled(False)

Problem

So I created a custom context menu, but I want to grey out some of the items in certain rows of my tree widget depending on certain values. How do I disable items on the menu? ``` myUI.setContextMenuPolicy( Qt.CustomContextMenu ) myMenu = QMenu( "Right Click Menu", myUI ) action = myMenu.addAction( "Item 1" ) action.triggered.connect( someFunction ) ```

Original source