PDA

View Full Version : QT application not close after close the mainwindow



artome
22nd July 2011, 21:09
Hi,

I have an application that stays in memory even after closing the mainwindow.
I think that this behavior is recent so I really don't know if this has something to do with recent QT updates.

My application is an mdi aplication were the main window has a mdiarea and a treeview.
looking for this problem on the net I really improved the way I was closing the main window by using
eventclosed and close all the mdi childs before left. I even try to use a.setQuitOnLastWindowClosed(true); thatr shoud be the default. Burt the result is the same.

my system is opensuse14.4 and QT 4.7.3-186.1-X86_64

any help would be appreciated.

I join may main.cpp where cloud class is the mainwindow class.





#ifdef WIN32
#include <winsock2.h>
#include <windows.h>
#endif


#include <QtGui/QApplication>
#include <QCleanlooksStyle> //para comentar se quisermos deixar o default do sistema
#include "cloud.h"


int main(int argc, char *argv[])
{
setlocale(LC_ALL, "C");
QApplication a(argc, argv);
// a.setQuitOnLastWindowClosed(true);
a.setStyle("Cleanlooks"); //para comentar se quisermos deixar o default do sistema
// a.setQuitOnLastWindowClosed(false);


Cloud w;

w.show();

return(a.exec());

Added after 1 15 minutes:

more information on this problem
I just add the line
w.setAttribute(Qt::WA_DeleteOnClose);
before
w.show();

And now the program crashes on close.
only starting the program and closing the main windows without performing any task
I get the signal when trying to debug in qtcreator



The inferior stopped because it received a signal from the Operating System.

Signal name :
SIGABRT
Signal meaning :
Aborted


because I did nothing other than start and close the program all the calls shown of in the debuger are calls to system it crashes in raise function in /lib64/libc.so.6

artome
22nd July 2011, 23:23
adding the line
w.setAttribute(Qt::WA_QuitOnClose);
seemed to have solved the problem.