[PyQt] signal twice emit

David Boddie dboddie at trolltech.com
Tue Jun 29 20:14:37 BST 2010


On Tue Jun 29 18:42:37 BST 2010, Csaba Toth wrote:

> Thanks for the advices, but this happens just with the most recent
> versions of PyQt, i think it started to appear after i upgradeed to 4.7.
> I used all versions from the 4.7 era, don't remember if it happened at
> the early versions, but with the most recent version it does.

It would be interesting to try it with an earlier version if possible, though
I could understand if that's not possible.

On Tue, Jun 29, 2010 at 3:06 PM, Csaba Toth wrote:
> 
> def p(self, clicked=False):
>     print('emitted')
> self.connect(self.btn_save, QtCore.SIGNAL("clicked(bool)"), self.p)

Initially, I thought this could be a problem with both the clicked() and the
clicked(bool) signals being connected to the slot, but that shouldn't happen
if the signature is used like this. You could check to see if the behavior
changes by decorating p() like this:

  @pyqtSlot("bool")
  def p(self, clicked=False):
      print('emitted')

It's difficult to know exactly what could cause this without some more
context. I've seen code that uses signal-slot auto-connection and also
includes connect() calls, resulting in double connections.

David
-- 
David Boddie
Senior Technical Writer
Nokia, Qt


More information about the PyQt mailing list