[PyQt] connect some times doesn't work with lambda syntax

IloChab ilochab at gmail.com
Fri Sep 5 21:05:13 BST 2008


Few weeks ago I posted here to find help about a problem with my application
[http://www.mail-archive.com/pyqt@riverbankcomputing.com/msg14774.html] :
running the very same code on different operating systems produced
different results.

In particular on Fedora9 and Mac-OsX my program never registered
sqlite db variations on disk, using Qt4's APIs, while every thing
worked fine on Fedora 8 and Windows.

No one answered to me and I was hopeless to find a solution.
So I rolled back onto older versions of my software, till I found a
version that worked every where.
Then applying one by one all the differences  to my code, I was able
to identify the cause, but I wasn't able to understand it, so I ask an
other time for help.

This is the 'wrong' code:
        self.connect(self,
            QtCore.SIGNAL("customContextMenuRequested(const QPoint &)"),
            lambda coord: self.ctxmenu.popup(self.mapToGlobal(coord)))

I had to substitute it with:
        self.connect(self,
            QtCore.SIGNAL("customContextMenuRequested(const QPoint &)"),
            self.showCntxMenu)
    def showCntxMenu(self, coord):
        self.ctxmenu.popup(self.mapToGlobal(coord))

The different syntax didn't effect the program behaviour during the
show of the context menu, but it affected in some way the status of
the code in such a way that pysqlite wasn't able any more to write on
disk, without signalling any error at all.

Do you have an explanation or it could be a bug??

Ciao.
Licia


More information about the PyQt mailing list