How does a PyQt Slot access a different class' object function? OO newbie confusion!
-
wrote on 29 Jul 2014, 00:01 last edited by
So I have a window class ui file that has all the buttons and functions that take care of the display..
My application's .py file loads/instantiates the window class, but it also does non-gui type stuff and therefore has non-gui related objects.
What I'd like to do, for example is whenever a button is pressed, the non-gui object's function gets called.
Architecturally or syntaxically (?) how is this typically performed? Should the windows class inherit from these non-window type classes? I'm sure I can make the objects functions into global functions, but doesn't that defeat the OO spirit?
-
Hi,
You can follow more or less the same rules that would apply in C++ here.
-
wrote on 2 Aug 2014, 00:55 last edited by
Here's an example in case that's what you were looking for. self.someButton is a QPushButton, and self.someObject is the object with the onClick method that will be called when the signal is emitted.
@
self.someButton.clicked.connect(self.someObject.onClick)
@ -
wrote on 2 Aug 2014, 20:23 last edited by
Thanks! That's what I as looking for!
[quote author="elveatles" date="1406940916"]Here's an example in case that's what you were looking for. self.someButton is a QPushButton, and self.someObject is the object with the onClick method that will be called when the signal is emitted.
@
self.someButton.clicked.connect(self.someObject.onClick)
@[/quote]
1/4