PyQt requires a "Mandatory" 'from qt import *' ...?

Alex Martelli aleax at aleax.it
Thu Apr 11 13:34:12 EDT 2002


Studying PyQt (latest releases of everything), I started noticing 
segmentation faults as I quit my application and eventually whittled it 
down back to...:

#!/usr/bin/env python2.2

import sys
import qt
# from qt import *

class MyWidget(qt.QWidget):

    def __init__(self, parent=None, name=None):
        qt.QWidget.__init__(self, parent, name)

        self.quit = quit = qt.QPushButton("Quit", self, "quit")
        self.connect(quit, qt.SIGNAL("clicked()"), qt.qApp, 
qt.SLOT("quit()"))


a = qt.QApplication(sys.argv)

w = MyWidget()
a.setMainWidget(w)
w.show()
a.exec_loop()


With the latest releases of Qt / sip / PyQt and Python, this gives me a 
Segmentation Fault (Mandrake 8.1, btw) as I hit the Quit button.  No
fault if I kill the app with the cross in the upper right corner (KDE).

BUT -- if I uncomment the "from qt import *" (of which I shouldn't
be using any part, as I loathe said usage)... the Segmentation
Fault goes away!

I'm a bit puzzled -- there must be something strange in the order of
finalization going on.  I can't believe I have to "import *" to make
my applications terminate gracefully -- perhaps just one or two
things from the qt module might suffice?

If anybody has more insight or can suggest more graceful workarounds,
please let me know!


Alex




More information about the Python-list mailing list