0

Using PySide (or Qt, PyQt), I can connect signal and slot like that

    self.myButton = QPushButton("My Button", self)
    self.myButton.clicked.connect(self.doSomething)

def doSomething(self, *args):
    ....

At this moment, can I get the slot outside of the class? I know the name of the function "doSomething", but I hope to know the way to getting the slot programmatically .

I am creating a ui tool for Maya, and within the ui I want to create a shelf button with the command that QPushButton executes. In maya, I can create a shelf button on the active shelf tab by clicking a menu item holding Ctrl+Shift. So I just want to keep the rule. When I click a QPushButton holding Ctrl+Shift, it creates a shelf button on the shelf tab. Of course, I can just store the command as a variable in QPushButton, but it does not seem programmatical :)

Darkgaze
  • 2,280
  • 6
  • 36
  • 59
Hyun-geun Kim
  • 919
  • 3
  • 22
  • 37
  • Possible duplicate of [Given a pyqtBoundSignal how to determine the slot?](http://stackoverflow.com/questions/22622434/given-a-pyqtboundsignal-how-to-determine-the-slot) – ekhumoro Sep 01 '16 at 17:42
  • No, you can't do this. But maybe you should explain *why* you want to do this, as there are probably better alternatives available. – ekhumoro Sep 01 '16 at 17:44
  • Your question is not clear. Please be concise! What do you mean by getting the slot out of the class... you mean the function doSomething? If you want to detect if you are pressing Ctrl+Shift when you press the button, you can test that in "doSomething". Please, modify the title of your post. – Darkgaze Sep 06 '16 at 08:00
  • I believe the only solution is to connect all slots/signals through your function that record each connection in its own registry. – anatoly techtonik Sep 06 '16 at 09:19

0 Answers0