[PyQt] exclude item from context menu w/ toggleViewAction

John Ossenfort johnossenfort at yahoo.com
Fri Jul 9 17:33:19 BST 2010


Replying to my own post - I finally figured out the function that allows you to 
do this. It's a fairly obvious one too ;-)
toolbar.toggleViewAction().setVisible(False)

Hope that helps someone else to save a few hours...




----- Original Message ----
From: John Ossenfort <johnossenfort at yahoo.com>
To: pyqt at riverbankcomputing.com
Sent: Fri, July 9, 2010 9:16:11 AM
Subject: [PyQt] exclude item from context menu w/ toggleViewAction

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



      
_______________________________________________
PyQt mailing list    PyQt at riverbankcomputing.com
http://www.riverbankcomputing.com/mailman/listinfo/pyqt



      


More information about the PyQt mailing list