views:

59

answers:

1

Hello and Good Morning , I have problem using QT application . I am posting little code here

QApplication a(argc, argv);
QString path = qApp->applicationDirPath();
qApp->setQuitOnLastWindowClosed(false);
a.addLibraryPath(path+"/plugins");
TryQt w;
w.show();
return  a.exec();

this is how i am starting my Application . In the Application (TryQt) i am creating several other QWidgets and Qwindows . The problem arises when I close the application The QMainWindow disappear seems like Program exited but it remains in the memory . ( I can see from Task Manager / Processes ) . I am also catching the closeEvent in my TryQt program and closing every thing possible i oppend in there . but still no use does any one has any idea why this is happening. thanks .//////

+2  A: 

well, it's because you're calling

qApp->setQuitOnLastWindowClosed(false);

the docs say:

This property holds whether the application implicitly quits when the last window is closed.

The default is true.

If this property is true, the applications quits when the last visible primary window (i.e. window with no parent) with the Qt::WA_QuitOnClose attribute set is closed. By default this attribute is set for all widgets except for sub-windows. Refer to Qt::WindowType for a detailed list of Qt::Window objects.

and you are for some reason setting it to false.

shoosh
changing qApp->setQuitOnLastWindowClosed(false); to True still not changing any thing. its not exiting the programme even though main Window has been closed.