volk
volk

Reputation: 63

How can I pass to a slot more than the arguments the signal sends in pyqt4?

I am writing a python plasmoid for KDE4.

I have a QHttp object which emits the signal "done (bool)" and i assign it to my functionB. I want to pass to functionB the valueA too. If I pass the value using lambda, the signal never triggers functionB.

def functionA(self):
  self.http=QHttp()
  ...
  valueA="valueA"
  self.connect(self.http, SIGNAL("done (bool)"), lambda valueA: self.functionB)
  self.get("/myurl.html")

def functionB(self, done, valueA):
  ...

Any ideas?

Upvotes: 2

Views: 73

Answers (1)

Janne Karila
Janne Karila

Reputation: 25197

Your lambda does not call functionB. Try if this works:

lambda done: self.functionB(done, valueA)

EDIT. Perhaps this approach would be better:

def functionA(self):
  self.http=QHttp()
  ...
  self.valueA="valueA"
  self.connect(self.http, SIGNAL("done (bool)"), self.functionB)
  self.get("/myurl.html")

def functionB(self, done, valueA=None):
  if valueA is None: 
      valueA = self.valueA
  ...

Upvotes: 1

Related Questions