Disconnect slot when another is being connected
Hi,
I have a QPushButton, in a QDialog, that has its signal "clicked()" connected to one slot that is part of the Dialog.
I want that someone, externally of this Dialog, connects to same signal then disconnects from the other slot.
I want a QPushButton that can has only one slot connected to its signals "clicked()"
I see this function:
QObject::connectNotify(const char * signal)
But notifies when the connection is already made. So if I overload this function to do something like this:
Code:
void CMyButton::connectNotify(const char * signal)
{
this->disconnect(SIGNAL(signal));
// How to connect the last signal-slot made?
}
I disconnect all, including the last connection made that I want to keep.
Any ideas??
Thanks
Re: Disconnect slot when another is being connected
If you want to have only one listener, it might be easier to not use signals and slots at all - just provide a "setListener()" method where you will pass a pointer to the object you want notified.
Re: Disconnect slot when another is being connected
Yes, I'm so focused in signals/slots that I forgot the "old-ways".
The only thing is that in all the app we're using the signal/slot mechanism I don't want to be different here.
Thank you.
Re: Disconnect slot when another is being connected
But signals and slots is a way of notifing environment of an object about changes in the object. You shouldn't assume that only one person will be listening to that. So you're breaking the signal/slot paradigm anyway.
Re: Disconnect slot when another is being connected
You're right.
Is too tricky/dirty and at last it will be confusing because I break the signals/slots paradigm.
Thank you :)