On Wednesday 09 February 2005 09:59, Eli Yukelzon wrote:
> Hi there.
>
> Sorry to be a nag, but can any of you suggest atleast some
> temporary (even ugly) solution for my closeEvent problem, until a
> better solution (wink in Torsten's direction) is available ?
see attached file. Seems like the seqfault was due to some dtor races,
which isn't surprising in that construct..
Hth, invoice follows ;-)
Pete
# -*- coding: utf-8 -*-
# Form implementation generated from reading ui file 'testform.ui'
#
# Created: Sun Feb 6 10:26:44 2005
# by: The PyQt User Interface Compiler (pyuic) 3.13
#
# WARNING! All changes made in this file will be lost!
import sys
from qt import *
class Form2(QMainWindow):
def __init__(self,parent = None,name = None,fl = 0):
QMainWindow.__init__(self,parent,name,fl)
self.statusBar()
if not name:
self.setName("Form2")
self.setCentralWidget(QWidget(self,"qt_central_widget"))
self.pushButton13 = QPushButton(self.centralWidget(),"pushButton13")
self.pushButton13.setGeometry(QRect(70,30,136,27))
self.languageChange()
self.resize(QSize(267,124).expandedTo(self.minimumSizeHint()))
self.clearWState(Qt.WState_Polished)
self.connect(self.pushButton13,SIGNAL("clicked()"),self.close)
def languageChange(self):
self.setCaption(self.__tr("Form2"))
self.pushButton13.setText(self.__tr("pushButton13"))
def closeEvent(self, e):
print "in close event"
e.accept()
def __tr(self,s,c = None):
return qApp.translate("Form2",s,c)
def init(self):
self.statusBar().hide()
class Form3(QMainWindow):
def __init__(self,parent = None,name = None,fl = 0):
QMainWindow.__init__(self,parent,name,fl)
self.statusBar()
#self.installEventFilter(self )
self.clearWState(Qt.WState_Polished)
def eventFilter(self, object, event):
if event and event.type() == QEvent.Close: # or event.type() == QEvent.Hide):
print "woohoo"
self.ui.removeEventFilter(self)
return False
def closeEvent(self, e):
print "in close event"
e.accept()
def init(self, w):
self.ui = w
self.ui.installEventFilter(self)
self.statusBar().hide()
if __name__ == "__main__":
a = QApplication(sys.argv)
QObject.connect(a,SIGNAL("lastWindowClosed()"),a,SLOT("quit()"))
if False:
w = Form2()
a.setMainWidget(w)
w.init()
w.show()
else:
import qt_ui_loader
wnd = Form3()
wnd_c = qt_ui_loader.create( 'testform.ui', wnd,None,True )
a.setMainWidget(wnd_c)
wnd.init(wnd_c)
#from new import instancemethod
#wnd_c.closeEvent = instancemethod(wnd.closeEvent,wnd_c,wnd_c.__class__)
wnd_c.show()
a.exec_loop()
_______________________________________________
PyKDE mailing list [email protected]
http://mats.imk.fraunhofer.de/mailman/listinfo/pykde