Qt application remains in memory even after closing MainWindow

The problem is this: if the application is closed while it is not actively doing something, it terminates correctly. However, if he is actively working on something (for example, waiting for a while loop), the main window closes, but the program will continue to work in the background, which is confirmed by opening the task manager.

I spent most of the day looking for a problem and implementing possible fixes, but to no avail. It seems that the quit () function just does nothing. Here are some things I've tried:

  • Using app.connect( &app, SIGNAL(lastWindowClosed()), &app, SLOT(quit())); . I know that the signal is triggered because I tried to change &app, SLOT(quit()) to qApp, SLOT(aboutQt()) , and the aboutQt window briefly appeared.
  • Includes qApp->quit(); at the beginning of the function that is launched from the button of the main window. The application works with this line, but has no effect.
  • Using processEvents() to make sure the GUI is updated.
  • Including expressions such as mainWindow.setAttribute(Qt::WA_QuitOnClose); in main.cpp.

I just want the application to exit completely when the main window is closed.

I use the qextserialport library if that matters.

+6
source share
1 answer

I do not know what is wrong, but since your slot really receives a signal, you can call exit() from this function of the slot as a workaround.

+1
source

Source: https://habr.com/ru/post/905756/


All Articles