本文整理汇总了Python中PyQt4.QtGui.QListView.eventFilter方法的典型用法代码示例。如果您正苦于以下问题:Python QListView.eventFilter方法的具体用法?Python QListView.eventFilter怎么用?Python QListView.eventFilter使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PyQt4.QtGui.QListView
的用法示例。
在下文中一共展示了QListView.eventFilter方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: eventFilter
# 需要导入模块: from PyQt4.QtGui import QListView [as 别名]
# 或者: from PyQt4.QtGui.QListView import eventFilter [as 别名]
def eventFilter(self, obj, event):
'''
@param obj QObject
@paramn event QEvent
'''
# if (event.type() == QEvent.MouseButtonPress):
# print "Mouse pressed"
#
if (event.type() == QEvent.ContextMenu):
# Now we know that event is an instance of QContextMenuEvent
menu = QMenu(self)
newPos = self.adjustPosition(event.pos())
modelIndex = self.indexAt(newPos)
self.showTransactions = QAction(self.tr("Show transactions"), self)
menu.addAction(self.showTransactions)
self.connect(self.showTransactions,
SIGNAL("triggered()"),
lambda : self.parentWindow.showTransactionsForPosition(modelIndex))
self.openWebpage = QAction(self.tr("Open Google Finance webpage"), self)
menu.addAction(self.openWebpage)
self.connect(self.openWebpage,
SIGNAL("triggered()"),
lambda : self.parentWindow.openWebpageForPosition(modelIndex))
menu.exec_(event.globalPos())
return QListView.eventFilter(self, obj, event)