[PyQt] exclude item from context menu w/ toggleViewAction

John Ossenfort johnossenfort at yahoo.com
Fri Jul 9 17:16:11 BST 2010


Hi all,

I have created several QDockWidgets surrounding a central widget, and I then 
added toggleViewAction to the windows so that they would appear in a context 
menu and I could check/uncheck them. That all worked fine and I was very happy. 
Then I added a QToolBar to the window, and that ALSO appeared in the context 
menu, with the window title (or toolbar title in my case) automatically being 
added without me enabling the toggleViewAction on the toolbar. Can anyone tell 
me how to disable this, i.e. - remove the toolbar entry from the context menu? A 
similar question might be, how would one specify that only some QDockWidgets are 
added to the context menu, but not all? Default behavior seems to be all or 
nothing.

I have tried both: 
        toolbar.toggleViewAction().setEnabled(False)
        toolbar.toggleViewAction().setMenu(None)
        Any other ideas?

Thank you
Jon



      


More information about the PyQt mailing list