本文整理汇总了Python中view.View.setContextMenuPolicy方法的典型用法代码示例。如果您正苦于以下问题:Python View.setContextMenuPolicy方法的具体用法?Python View.setContextMenuPolicy怎么用?Python View.setContextMenuPolicy使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类view.View
的用法示例。
在下文中一共展示了View.setContextMenuPolicy方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: Window
# 需要导入模块: from view import View [as 别名]
# 或者: from view.View import setContextMenuPolicy [as 别名]
class Window(QWidget):
def __init__(self, dbg=False):
super(Window, self).__init__()
self.view = View(self)
s = QShortcut(self)
s.setKey(Qt.Key_Tab)
s.activated.connect(self.tabKeyPressed)
self.splitter = QSplitter(self)
self.splitter.setOrientation(Qt.Vertical)
layout = QVBoxLayout(self)
layout.setMargin(0)
layout.addWidget(self.splitter)
self.splitter.addWidget(self.view)
if dbg:
self.setupInspector()
self.splitter.addWidget(self.inspector)
else:
self.view.mouseDoubleClickEvent = lambda e: e.ignore()
self.view.mouseMoveEvent = lambda e: e.ignore()
self.view.mousePressEvent = lambda e: e.ignore()
self.view.mouseReleaseEvent = lambda e: e.ignore()
self.view.wheelEvent = lambda e: e.ignore()
self.view.setContextMenuPolicy(Qt.NoContextMenu)
def tabKeyPressed(self):
e = QKeyEvent(QEvent.KeyPress, Qt.Key_Tab, Qt.NoModifier)
self.view.keyReleaseEvent(e)
def setupInspector(self):
page = self.view.page()
page.settings().setAttribute(QWebSettings.DeveloperExtrasEnabled, True)
self.inspector = QWebInspector(self)
self.inspector.setPage(page)
shortcut = QShortcut(self)
shortcut.setKey(Qt.Key_F12)
shortcut.activated.connect(self.toggleInspector)
self.inspector.setVisible(False)
def toggleInspector(self):
self.inspector.setVisible(not self.inspector.isVisible())
def closeEvent(self, event):
App.backend.evalJS('ui.saveState()')
pass