0

I have a main QApplication (with a single QMainWindow) which starts a sub-process running another QApplication with several QMainWindows. These QMainWindows save their position and size when closed, as I defined in the closeEvent() method. The problem: When I quit the main QApplication by closing its QMainWindow, the QMainWindows in the subprocess are closed without receiving a closeEvent, and consequently do not store their position and size. The question: What is the solution ? Thanks

user3650925
  • 173
  • 1
  • 10
  • How are you shutting down the "subprocesses"? And what do you mean by "subprocesses"? Are these threads, or are they separate, standalone applications that your main application keeps track of? And why are they "subprocesses" rather than just additional main windows? – goug Dec 08 '16 at 19:55
  • Hi Goug, Only one QApplication can exist per Process. My Main QApplication runs in the main Process. In this Process I create another Process (which I call a subprocess), in which another QApplication is run. I don't shut down the subprocess by program. When I click the closing box of the main window, the window is closed, then a quit() event is probably generated, which probably leads to killing automatically the subprocess (but I am not sure). The problem is that the windows of this subprocess are closed in a dirty way... – user3650925 Dec 08 '16 at 22:21
  • I agree they're probably being killed without prejudice. Are you using QProcess to start your sub processes, or some other technique? If you're using QProcess, you might try calling QProcess::terminate on each child process when your main application is asked to shut down. Be sure to check the docs on that for caveats. – goug Dec 08 '16 at 22:44
  • No, I don't use QProcess, but I instantiate a CodeProcess, which is a class subclassing the Process class from multiprocessing. Then a QApplication is instantiated from inside the CodeProcess. – user3650925 Dec 08 '16 at 22:59
  • CodeProcess and Process aren't Qt-related, so you're probably in the wrong forum for help on that. The only thing I can think of is to add a signal handler to your processes that receive the kill signal and properly close the windows. This post may be useful: http://www.qtcentre.org/threads/43413-How-to-make-a-clean-exit-when-application-is-terminated-by-quot-kill-quot-command – goug Dec 08 '16 at 23:36

0 Answers0