PySide: Returning a value from a slot

后端 未结 2 1549
执念已碎
执念已碎 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".

提交回复
热议问题