[PyQt] Catching Qt exceptions in PyQt

Allen Bierbaum abierbaum at gmail.com
Fri Sep 7 17:20:39 BST 2007


I don't know what you are doing wrong or what causes this, but I do
know that we see it all the time when trying to debug and it makes the
entire process very painful.  If you find any type of solution that
works so you can see the exception that is being thrown, please let me
know so we can use it.

-Allen

On 9/7/07, Dirk Wagener <dwagen at stonethree.com> wrote:
> Hi
>
> I have a piece of code that produces this error:
>
> "Qt has caught an exception thrown from an event handler. Throwing
> exceptions from an event handler is not supported in Qt.
> You must reimplement QApplication::notify() and catch all exceptions
> there. "
>
> I implemented my own app class as follows:
>
> class Application (QtGui.QApplication):
>     def __init__(self, argv):
>         QtGui.QApplication.__init__(self, argv)
>
>     def notify(self, obj, evt):
>         try:
>             # Call base class notify.
>             return QtGui.QApplication.notify(self, obj, evt)
>         except Exception:
>             print "Unexpected error:",
> string.join(traceback.format_exception(*sys.exc_info()))
>             return False
>
> My code still produces exactly the same error, so it seems that the
> exception is still not caught!
> What am I doing wrong here?
>
> Kind regards
> Dirk Wagener
> _______________________________________________
> PyQt mailing list    PyQt at riverbankcomputing.com
> http://www.riverbankcomputing.com/mailman/listinfo/pyqt
>


More information about the PyQt mailing list