4

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 )

1 Answer 1

14

To disable a menu item, just disable the QAction

action.setEnabled(False)
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.