Signal connect with different class
-
hai,
sorry i have a problem to paste the code here. my code http://pastebin.com/kL3Q6B3W
my question is:
@
self.connect(self.lineedit, QtCore.SIGNAL("returnPressed()"), MyDisplay.updateUi())
@
can i send the signal (emitted by self.lineedit) to another class which is defined by MyDisplay.updateUi???or anyone have the example code please tell me
thanks
-
Disclaimer: I am not familiar with PyQt (or much with Python at all, in fact).
There is no problem at all connecting signals and slots between different classes, as long as those classes are both QObject derived. So in fact, you are connecting two QObjects always.
-
[quote author="ictsecurity0" date="1313646336"]hai,
@
self.connect(self.lineedit, QtCore.SIGNAL("returnPressed()"), MyDisplay.updateUi())
@
[/quote]The syntax should be the same on PyQt as on C++:
@
self.connect(self.lineedit, QtCore.SIGNAL("returnPressed()"), MyDisplay, QtCore.SLOT("updateUi()"))
@ -
[quote author="Volker" date="1313663456"]
[quote author="ictsecurity0" date="1313646336"]hai,
@
self.connect(self.lineedit, QtCore.SIGNAL("returnPressed()"), MyDisplay.updateUi())
@
[/quote]The syntax should be the same on PyQt as on C++:
@
self.connect(self.lineedit, QtCore.SIGNAL("returnPressed()"), MyDisplay, QtCore.SLOT("updateUi()"))
@[/quote]
still got the error. I tried alot of method to pass the signal of 'returnPassed()' to another class.
the error"IdentationError:expected an indented block..
My code is here http://pastebin.com/wBhWGxCX
i just want to do some simple print feature but failed
thanks
-
[quote author="ictsecurity0" date="1313735715"]
still got the error. I tried alot of method to pass the signal of 'returnPassed()' to another class.the error"IdentationError:expected an indented block..
[/quote]
I'm by no means a Python export, but that error message looks quite unrelated to Qt... Did you mix up spaces and tabs?
-
i solved the problem with using lambda:
self.connect(lineedit, QtCore.SIGNAL('returnPressed()'), lambda: MyDisplay().updateUi())
anyway, thanks :)