Qt中QMainWindow右上角的红叉是响应的哪个函数?该如何解决

Qt中QMainWindow右上角的红叉是响应的哪个函数?
Qt中QMainWindow右上角的红叉是响应的哪个函数?
我发现点击窗口右上角的红色叉叉后,不是响应的close(),应该响应的MFC中Destroy()之类的函数,而且进入~CMyWindow()析构函数之前调用这个函数。
怎么找出来呢?
Qt中QMainWindow右上角的红叉是响应的哪个函数?该如何解决
------解决方案--------------------
void QWidget::closeEvent(QCloseEvent * event) [virtual protected]

------解决方案--------------------
void QWidget::closeEvent(QCloseEvent * event) [virtual protected]
This event handler is called with the given event when Qt receives a window close request for a top-level widget from the window system.

By default, the event is accepted and the widget is closed. You can reimplement this function to change the way the widget responds to window close requests. For example, you can prevent the window from closing by calling ignore() on all events.

Main window applications typically use reimplementations of this function to check whether the user's work has been saved and ask for permission before closing. For example, the Application Example uses a helper function to determine whether or not to close the window:

void MainWindow::closeEvent(QCloseEvent *event)
{
    if (maybeSave()) {
        writeSettings();
        event->accept();
    } else {
        event->ignore();
    }
}