[PyKDE] qApp is a QApplication instance

Giovanni Bajo rasky at develer.com
Mon Mar 21 17:02:26 GMT 2005


Phil Thompson <phil at riverbankcomputing.co.uk> wrote:

>> Well, it doesn't even pass the basic sanity check:
>>
>>>>> from qt import *
>>>>> class App(QApplication):
>> ...     pass
>> ...
>>>>> a = App([])
>>>>> qApp
>> <qt.QApplication object at 0x0080DCF0>
>>>>> import sip
>>>>> sip.cast(qApp, App)
>> Traceback (most recent call last):
>>   File "<stdin>", line 1, in ?
>> SystemError: error return without exception set
>>
>> I speculate this got broken when you touched exception support in sip
4.2?
>
> You haven't called QApplication.__init__().


It is automatically invoked because there is no App.__init__ (unless your
sip.wrappertype metaclass does something funky). Anyway, I tried defining a
simple forwarder and nothing changes:

>>> from qt import *
>>> class App(QApplication):
...     def __init__(self, *args):
...             QApplication.__init__(self, *args)
...
>>> a = App([])
>>> qApp
<qt.QApplication object at 0x0080DCF0>
>>> import sip
>>> sip.cast(qApp, App)
Traceback (most recent call last):
  File "<stdin>", line 1, in ?
SystemError: error return without exception set

-- 
Giovanni Bajo




More information about the PyQt mailing list