Qt - register multiple signals that when they've all emitted produce a giant signal connected to one slot

StackOverflow https://stackoverflow.com/questions/14904050

質問

In my application I have the following situation:

  • an object emits signal removeCharacter
  • removeCharacter has a part A and B, and after part A is done it fires signal removePath
  • slot onRemovePath is connected to signal removePath and will remove the path for the character and then fire a signal pathRemoved
  • slot finishRemovingCharacter is connected to signal pathRemoved and will finish the rest of the character removal process
  • I don't want to always execute this finishRemovingCharacter logic when I fire the removePath signal

Is there some generic way to achieve the above, preferably something that Qt may already have available?

EDIT: I was hoping there would be a generic way to specify a sequence of signal and slot processing, instead of needing an intermediate slot to send a signal that it is done so the next step can execute.

役に立ちましたか?

解決

As I see it, there are only two ways to handle with the situation.

Option 1:
Use two signals for the pathRemoved event. For example finishRemovingCharacter is connected to pathRemoved but NOT to pathRemovedSpecial.

Option 2:
Add proper arguments to the pathRemoved signal and then in the finishRemovingCharacter slot check if it should continue or just ignore this event in which case you'll just return;.

ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top