Reimplement the reject slot for the parent dialog class
This commit is contained in:
@@ -30,8 +30,8 @@ from __future__ import annotations
|
|||||||
from enum import Enum
|
from enum import Enum
|
||||||
from typing import TYPE_CHECKING
|
from typing import TYPE_CHECKING
|
||||||
|
|
||||||
from PyQt5.QtCore import QSize, Qt
|
from PyQt5.QtCore import QSize, Qt, pyqtSlot
|
||||||
from PyQt5.QtGui import QKeyEvent, QKeySequence, QWheelEvent
|
from PyQt5.QtGui import QWheelEvent
|
||||||
from PyQt5.QtWidgets import (
|
from PyQt5.QtWidgets import (
|
||||||
QApplication, QComboBox, QDialog, QDoubleSpinBox, QSpinBox, QToolButton,
|
QApplication, QComboBox, QDialog, QDoubleSpinBox, QSpinBox, QToolButton,
|
||||||
QWidget
|
QWidget
|
||||||
@@ -54,11 +54,11 @@ class NDialog(QDialog):
|
|||||||
self.setParent(None) # type: ignore
|
self.setParent(None) # type: ignore
|
||||||
return
|
return
|
||||||
|
|
||||||
def keyPressEvent(self, event: QKeyEvent) -> None:
|
@pyqtSlot()
|
||||||
"""Overload keyPressEvent and forward escape to close."""
|
def reject(self) -> None:
|
||||||
if event.matches(QKeySequence.StandardKey.Cancel):
|
"""Overload the reject slot and also call close."""
|
||||||
self.close()
|
super().reject()
|
||||||
event.ignore()
|
self.close()
|
||||||
return
|
return
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user