Signal connect with different class
-
wrote on 18 Aug 2011, 05:45 last edited by
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
-
wrote on 18 Aug 2011, 06:29 last edited by
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.
-
wrote on 18 Aug 2011, 10:30 last edited by
[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()"))
@ -
wrote on 19 Aug 2011, 06:35 last edited by
[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
-
wrote on 19 Aug 2011, 07:29 last edited by
The code in your pastebin has mismatched parenthesis, I think.
-
wrote on 19 Aug 2011, 11:41 last edited by
[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?
-
wrote on 20 Aug 2011, 05:04 last edited by
i solved the problem with using lambda:
self.connect(lineedit, QtCore.SIGNAL('returnPressed()'), lambda: MyDisplay().updateUi())
anyway, thanks :)
-
wrote on 20 Aug 2011, 08:27 last edited by
I think you could have solved it with just an additional closing parentheses ) after the connect statement in your original code...
8/8