@JonB said in Custom context menu in QtWebEngineView (in Python):
@Harborman
Have a go at https://stackoverflow.com/questions/66495337/how-to-customize-python-pyqt5-qwebengineview-context-menu.
Thank you. I managed to make a custom context menu using the information in that link. I put the webengine in its own class, and then made a completely new context menu using Qmenu.
Here's the working context menu test:
class Browser(QWebEngineView):
def __init__(self, *args, **kwargs):
super().__init__(*args, **kwargs)
def contextMenuEvent(self, event):
self.menus = QMenu()
self.menus.addAction('Save Image')
self.menus.popup(event.globalPos())
class MainWindow(QMainWindow):
def __init__(self, *args, **kwargs):
super(MainWindow, self).__init__(*args, **kwargs)
self.browser = Browser()
self.setCentralWidget(self.browser)
self.show()
self.browser.load(QUrl("http://duckduckgo.com"))
app = QApplication(sys.argv)
app.setApplicationName("Context Menu test")
window = MainWindow()
app.exec_()