I know that i can use QSignalMapper
to call a slot with different parameters based on connection. What i want to achieve is a little different.
We are using plugins in our application and different plugins are responsible for different types of objects. We are connecting multiple slots, each implemented in a different plugin, to one signal emitted by the main application. One of the parameters of the signal is a QString
indicating the type of object associated with the signal. Currently, we are checking this parameter in the slots and proceed if the type is handled by the plugin. This has a downside, every plugin does this checking and i want to avoid this if possible.
I want to connect all slots to the same signal, and when the signal is emitted, only the appropriate slot is called depending on the value of the QString
argument, kind of like a QSignalMapper
but in a different way.
Is there any built-in mechanism to do this? If not, any ideas on how i can achieve this?
Thank you in advance.
I don't think there's a component for that, but you could create your own signal mapper like this:
Qxt has a class exactly for this functionality. You can use QxtSlotMapper class which is in QxtCore module.
http://libqxt.bitbucket.org/doc/tip/qxtslotmapper.html
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With