Important: Please read the Qt Code of Conduct -

Application does not quit

  • I'm working on an application which does not quit even though

    • I close the last window
    • quitOnLastWindowClosed is set to true
    • the signal "QApplication::lastWindowClosed" is emitted.

    I checked all above with the following code:

    QObject::connect(&app, &QApplication::lastWindowClosed, []{
            qDebug() << "Last window closed!";
            qDebug() << "Quit on last window closed: " << qApp->quitOnLastWindowClosed();
            //QApplication::postEvent(qApp, new QEvent(QEvent::Quit));

    If I uncomment the last line, the application quits.

    Is this a bug? Or am I doing something wrong?

  • Moderators

    @fxrh said in Application does not quit:

    Is this a bug?

    Possibly, but provide MWE that reproduces the issue and the relevant specs (OS, Qt version, window manager etc.) with which you experience it.

    Or am I doing something wrong?

    Not from what I can see.

  • @kshegunov Thank you! I'm not sure I'll be able to provide a MWE, as I'm out of ideas what could cause this.

Log in to reply