Wasabi
7th October 2010, 20:56
I've looked through the webs for an answer to this question which I'm sure has been answered a few dozen times before, but I can't find anything regarding it, so...
How can I re-cast a SIGNAL or SLOT? For instance, I have a QCheckBox which I want to connect to a QLineEdit so that if the Box is unchecked, the LineEdit is disabled.
My first idea was of course to use:
connect(box,SIGNAL(stateChanged(int)),LineEdit,set Enabled(bool)));
Since stateChanged emits a 0 if unchecked and a 2 if checked (1 if partially checked, which isn't relevant in my case), that'd work well.
However, as I was already aware, the SIGNAL and SLOT need to have the same arguments. I was hoping that since int can be implicitly cast to a bool (0 == false, everything else == true), it'd work, but it doesn't.
So now I'm stuck. Any hints?
How can I re-cast a SIGNAL or SLOT? For instance, I have a QCheckBox which I want to connect to a QLineEdit so that if the Box is unchecked, the LineEdit is disabled.
My first idea was of course to use:
connect(box,SIGNAL(stateChanged(int)),LineEdit,set Enabled(bool)));
Since stateChanged emits a 0 if unchecked and a 2 if checked (1 if partially checked, which isn't relevant in my case), that'd work well.
However, as I was already aware, the SIGNAL and SLOT need to have the same arguments. I was hoping that since int can be implicitly cast to a bool (0 == false, everything else == true), it'd work, but it doesn't.
So now I'm stuck. Any hints?