Béatrice M.
Béatrice M.

Reputation: 972

C++ Qt - Can QSignalMapper be cleared and re-used?

Consider a card game. Cards are drawn from a deck and displayed on screen. The cards are clickable, and lead to the same effect, so the use of QSignalMapper was obvious.

Now, consider discarding those cards, to draw new ones.

Is there a way to clear QSignalMapper, or is QSignalMapper automatically cleared when an object is removed from UI?

I thought about [QSignalMapper::removeMappings][1] ( QObject * sender ) but I am unsure about what 'sender' is.

Upvotes: 0

Views: 1469

Answers (1)

Chris
Chris

Reputation: 17535

The sender parameter is the same object that you gave as the first parameter to setMapping()

Additionally, it is worth noting what the documentation has to say under removeMappings():

This is done automatically when mapped objects are destroyed.

So if you're destroying objects that you've given to a SignalMapper, it will clean itself up when those objects are deleted.

Upvotes: 1

Related Questions