Nominate our 2022 Qt Champions!

[Solved]closeEvent() is not working when application is closing.

  • I have a sub class from QmlApplicationViewer in which i override the closeEvent() function, but it is not called when i press the cross on my window. Are there any other ways to catch my application is closing?
    Also tried Component.onDestroying on my root element in QML file, but in this case i think some of children of this item are deleted till that moment.

  • Perhaps i am doing something wrong?
    class Test : public QWidget
    virtual ~Test(){}
    void closeEvent(QCloseEvent *e)
    There is a break Point in 10 line, but debugger is not stopping on it.

  • Depending on what you're trying to do, the "QCoreApplication::aboutToQuit": signal may be helpful.

    EDIT: It's good to use the right class name.

  • mlong, thank you. QCoreApplication::aboutToQuit helped me.
    Even if i could not find why closeEvent is not working, i find my problem is solved.

Log in to reply