PySide: Returning a value from a slot

后端 未结 2 1542
执念已碎
执念已碎 2021-01-19 14:40

The Pyside documentation states that slots can have return values, but I have yet to figure out how make it do so.

I couldn\'t find any usable code samples on this,

相关标签:
2条回答
  • 2021-01-19 15:07

    I'm afraid what you think is not possible. Signals and slots are loosely coupled together, so emitting a signal does not directly call a slot, and therefore cannot retrieve "its" return value.

    This might be clearer if you think about this:

    You can connect 2 different slots (of e.g. 2 different classes), which return different values, to one signal. Which of the two return values are supposed to reach the variable you try to assign?

    What you probably mean is this: This is something completely different, and allows return values via "invoking" the method over the MetaObject system by "name".

    0 讨论(0)
  • 2021-01-19 15:19

    Perhaps you may "inject" whatever you want to return from testSlot function into a property of the class where the signal is emmited

    0 讨论(0)
提交回复
热议问题