How To Remove Standart Menuitem From Qtextedit Context Menu
Solution 1:
To get full control over the context menu, first use QWidget.setContextMenuPolicy to change the context meu policy to Qt.CustomContextMenu
. Then connect a handler to the QWidget.customContextMenuRequested signal. In the handler, you can then get a standard context menu object using the QTextEdit.createStandardContextMenu method.
Modify the menu as you see fit, and then show it using the QPoint
passed to the signal handler like this:
menu.exec_(textedit.viewport().mapToGlobal(point))
Solution 2:
Welcome to pyside! :-)
Since QTextEdit inherits QWidget you would probably want to set the context menu policy to custom and then supply you own popup menu
The reason i suggest creating your own custom context is because the qmenu isnt really accessible as a persistant object on the qtextedit. Its build on the fly basd on the context at the moment it was clicked. Im not sure there is a method you can overload to gain acces to the qmenu before it is shown. I think the best you can do is define your own completly.
Post a Comment for "How To Remove Standart Menuitem From Qtextedit Context Menu"