标签:
#QListView控件多选设置
self.ui.listView.setSelectionMode(QAbstractItemView.ExtendedSelection)
#初始化QListView控件焦点事件
self.ui.listView.installEventFilter(self)
#焦点响应事件
def eventFilter(self, widget, event):
#失去焦点
if event.type() == QtCore.QEvent.FocusOut:
print ‘focus out‘
#注意要有返回值 不然会出 TypeError: invalid result type from mouseoverEvent.eventFilter()
return False
#获得焦点
if event.type()==QtCore.QEvent.FocusIn:
print ‘focus in‘
return False
else:
# we don‘t care about other events
return False
标签:
原文地址:http://www.cnblogs.com/QUSIR/p/4606344.html