Qt: How do I handle the event of the user pressing the 'X' (close) button?

前端 未结 4 1095
佛祖请我去吃肉
佛祖请我去吃肉 2020-12-02 06:50

I am developing an application using Qt. I don\'t know which slot corresponds to the event of \"the user clicking the \'X\'(close) button of the window frame\" i.e. this but

4条回答
  •  谎友^
    谎友^ (楼主)
    2020-12-02 07:05

    also you can reimplement protected member QWidget::closeEvent()

    void YourWidgetWithXButton::closeEvent(QCloseEvent *event)
    {
        // do what you need here
        // then call parent's procedure
        QWidget::closeEvent(event);
    }
    

提交回复
热议问题