[英]How to disable contextMenu from QWebEngineView?
I want to disable the right click menu which appears by default when you create a QWebEngineView.我想禁用创建 QWebEngineView 时默认出现的右键单击菜单。
import sys
from PyQt5.QtWidgets import QApplication
from PyQt5.QtWebEngineWidgets import QWebEngineView
from PyQt5.QtCore import QUrl
app = QApplication(sys.argv)
webBrowser = QWebEngineView()
#Some line here to delete the contextMenu
webBrowser.load(QUrl("https://stackoverflow.com/"))
webBrowser.show()
sys.exit(app.exec_())
In the doc we can find a class QWebEngineContextMenuData which "provides context data for populating or extending a context menu with actions..." but nothing to delete in here?在文档中,我们可以找到一个QWebEngineContextMenuData类,它“提供用于填充或扩展带有操作的上下文菜单的上下文数据......”但这里没有什么可删除的?
要禁用默认小部件菜单,则必须将 contextMenuPolicy 设置为 Qt::NoContextMenu:
webBrowser.setContextMenuPolicy(Qt.NoContextMenu)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.