[prev in list] [next in list] [prev in thread] [next in thread] 

List:       pykde
Subject:    Re: [PyQt] Intercept close button and force application to Quit
From:       "Jonathan Harper" <jon () white-walls ! net>
Date:       2010-12-23 18:04:19
Message-ID: 000301cba2cb$d3ec7160$7bc55420$ () net
[Download RAW message or body]

>I have an application with several threads, one of which is a PyQT GUI,
>when I click on the close button, the PyQT GUI closes but the rest of
>the application keeps running, I would like to be able to intercept the
>close button event and force the whole application to quit.
>Does anybody know how I might do this?

Either: 1) subclass QApplication and re-implement exit() or 2) subclass
QMainWindow and re-implement the QMainWindow close() method--the latter
assumes you're using a QMainWindow or subclassed QMainWindow as the
top-level widget. If you're using a QDialog or something else, the relevant
methods would have to be fussed with. I usually go with subclassing
QApplication, since it will catch more than just a safe close() call to the
top-level widget (e.g. a qFatal error in one of the threads). There are
times when it would be necessary to subclass a child widget's close()
method, such as if that widget (e.g. a modal QDialog or an MdiSubWindow)
launched some helper threads. Otherwise, the QApplication.exit() route is
probably better.

-- Jon Harper

_______________________________________________
PyQt mailing list    PyQt@riverbankcomputing.com
http://www.riverbankcomputing.com/mailman/listinfo/pyqt
[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic