I created QInputDialog and configured event filter in it, but I don't know how to prevent it from closing on ESC or ENTER button click in eventFilter(self, widget, event)
method.
self.inDialog = QInputDialog(self)
#some config...
self.inDialog.setLabelText('')
self.nameAction.setText('&Nazwa pola głównego ✔')
self.inDialog.show()
My event filter concept:
def eventFilter(self, widget, event):
if isinstance(event, QtGui.QKeyEvent):
if event.key() == 16777220:
return False
# here I want to call super somehow?
return
It is worth mentioning that I am doing all this operations in QMainWindow class from which I am calling this QInputdialog. I would prefer not to subclass QDialog and write everything manually.
If you want to avoid that the event happens to the
QInputDialog
you must returnTrue
in the filter, on the other hand it is better to use theQt::Key
to make a more readable code.Update: + Disable close button: