python - PyQt QTableWidget signal emitted when selecting no rows -


i have qtablewidget in pyqt single row selection set. connecting itemselectionchanged call row selection function , take action on selected row. detect when user selects inside qtablewidget, selects empty space (no row selected), can deselect selected row. similar how "windows explorer" works file selections.

what signal triggered when selecting blank area inside qtablewidget? how can accomplished?

check mouse-press events see if clicked item none:

class table(qtgui.qtablewidget):     def mousepressevent(self, event):         if self.itemat(event.pos()) none:             self.clearselection()         qtgui.qtablewidget.mousepressevent(self, event) 

or if can't subclass, use event-filter:

class window(qtgui.qwidget):     def __init__(self):         ...         self.table.viewport().installeventfilter(self)      def eventfilter(self, source, event):         if (event.type() == qtcore.qevent.mousebuttonpress ,             source self.table.viewport() ,             self.table.itemat(event.pos()) none):             self.table.clearselection()         return qtgui.qwidget.eventfilter(self, source, event) 

Comments

Popular posts from this blog

Payment information shows nothing in one page checkout page magento -

tcpdump - How to check if server received packet (acknowledged) -