def eventFilter(self, obj, event): etype = event.type() if etype == event.KeyPress or etype == event.KeyRelease: if obj == self and event.key() == Qt.Key_UP or event.key( ) == Qt.Key_Down: self.parent().showPopup() return True elif event.key() == Qt.Key_Enter or \ event.key() == Qt.Key_Return or \ event.key() == Qt.Key_Escape: QComboBox.hidePopup(self.parent()) if event.key() != Qt.Key_Escape: return True elif etype == event.MouseButtonPress: self.parent()._containerMousePress = ( obj == self.parent().view().window()) elif etype == event.MouseButtonRelease: self.parent()._containerMousePress = False return False
def hidePopup(self): """This is to disable hiding of the popup when an item is clicked.""" if self._containerMousePress: QComboBox.hidePopup(self)