QDialog does not implement its close method, so we are looking at the base one:
bool QWidget :: close () [slot]
Closes this widget. Returns true if the widget was closed; otherwise returns false .
First it sends the widget a QCloseEvent . The widget is a hidden event. If it ignores the event, nothing happens. QWidget::closeEvent() accepts the close event.
If the widget has the Qt::WA_DeleteOnClose flag, the widget is also deleted. No matter what the widget is visible or not.
The QApplication::lastWindowClosed() signal with the Qt::WA_QuitOnClose attribute set is closed. For transient windows such as splash screens, tool windows, and popup menus.
That is, when you call close a window instance can be destroyed if the Qt::WA_DeleteOnClose flag is Qt::WA_DeleteOnClose .
But you can never use either close or destroy , but only creating an instance on the stack, instead of a class field, as the author of the question seems to do.
I usually create a small class with the getResult function for modal dialogs:
class MyTableDialog(QtGui.QDialog, ): __ui = None def __init__(self, parent): super(MyTableDialog, self).__init__(parent) ui = self.__ui = Ui_MyTableDialog() ui.setupUi(self) self.__my_setup_ui() def GetResult(self, *args, **kwds): self.__set_args_to_ui(*args, **kwds) if self.exec_() != self.Accepted: return return self.__get_res_from_ui() def __my_setup_ui(self): "Здесь дополнительно инициализируем интерфейс и связываем сигналы" def __set_args_to_ui(self, *args, **kwds): "Здесь устанавливаем данные в элементы интерфейса" def __get_res_from_ui(self): "Здесь вытаскиваем введённые в интерфейсе данные" # Пример использования class MyMainWindow(...): def GetUserTable(self, *args, **kwds): res = MyTableDialog(self).GetResult(*args, **kwds) if res is None: logging.info('Пользователь отказался от ввода') else: self.__parse_user_table_input(res)