[PyKDE] PyQt and lambda expressions doesn't like each other

Hans-Peter Jansen hpj at urpla.net
Mon Apr 28 18:13:00 BST 2003


On Monday 28 April 2003 16:42, Phil Thompson wrote:
> On Monday 28 April 2003 2:12 pm, Hans-Peter Jansen wrote:
> > On Monday 28 April 2003 14:53, Phil Thompson wrote:
> > > On Monday 28 April 2003 1:31 pm, Hans-Peter Jansen wrote:
> > > > This doesn't work (while it should):
> > > >
> > > > import sys
> > > > from qt import *
> > > >
> > > > app = QApplication(sys.argv)
> > > > button = QPushButton("&Hello World", None)
> > > > app.setMainWidget(button)
> > > > button.show()
> > > > app.connect(button, SIGNAL("clicked()"), lambda: app.exit(0))
> > > > app.exec_loop()
> > > >
> > > > Any ideas, why?
> > >
> > > connect() doesn't take a reference to a slot so it gets garbage
> > > collected immediately.
> >
> > This leaves the question, what are the consequences, if it would?
>
> A very high chance of circular references and, consequently, widgets
> that refuse to disappear.
>
> That was the original behaviour, many years ago.

How about adding this to the examples section for future reference:
-------------- next part --------------
A non-text attachment was scrubbed...
Name: qtlambda.py
Type: text/x-python
Size: 739 bytes
Desc: not available
Url : http://www.riverbankcomputing.com/pipermail/pyqt/attachments/20030428/c446ffb4/qtlambda.py


More information about the PyQt mailing list