[PyQt] Bug: PyQt causes Python to abnormally exit upon creating QWidget without a QApplication

Andreas Pakulat apaku at gmx.de
Thu Apr 9 13:36:45 BST 2009


On 09.04.09 13:45:47, Shriramana Sharma wrote:
> Hello. See the following:
>
> $ python
> Python 2.5.2 (r252:60911, Jul 31 2008, 17:28:52)
> [GCC 4.2.3 (Ubuntu 4.2.3-2ubuntu7)] on linux2
> Type "help", "copyright", "credits" or "license" for more information.
> >>> from PyQt4.QtGui import *
> >>> w = QWidget ()
> QWidget: Must construct a QApplication before a QPaintDevice
> $
>
> I think this should be handled more gracefully with a Python exception  
> (or error, if the two are not the same) thrown rather than Python  
> abnormally exiting, like follows:

PyQt has no control over that, this is happening in the C++ part and
QWidget uses qFatal() which in turn calls abort() at that point to end
the application. And thats actually the correct way for the C++ part to
handle this case (as Qt doesn't use exceptions).

Andreas

-- 
You definitely intend to start living sometime soon.


More information about the PyQt mailing list