PyQt: Basic example of accessing and adding submenus to an existing context menu?

Note. I have very little python and PyQt experience ...

Given the context menu already created, I am looking for a functional example of how to access this context menu, so it can be expanded for a plugin that executes the python javascript greasemonkey script equivalent.Then I also look for a functional example of how to add a submenu to this context menu . Thank!

+3
source share
2 answers

Avaris comments basically answered this question best. I can’t choose him because he is commenting, not the answer. Therefore, I summarize this answer here, so that Q can be answered:

" (QMenu ), ". -

" , [, ]. , QActions (. 301), QMenu. plugin_menu , ". -

, ( ), / , ( ) API. , API / /, .

+1

customContextMenuRequested / ( Qt), , , , / :

self.centralwidget.customContextMenuRequested.connect(self.context_menu_method)

self.context_menu_method, ,

, :

menu = QtGui.QMenu()
submenu = QtGui.QMenu(menu)
submenu.setTitle("Submenu")
menu.addMenu(submenu)
+2

All Articles