Create new signal for derived widget
Hi.
I wanted to make a check box widget which could emit a signal with an index whenever it's checked/unchecked.
I made a new class derived from QCheckBox which contains a data member that holds the box's index.
I want to override "stateChanged(int) signal to be "stateChabged(int,int)" so it will contain the index.
I created a new signal in the Qt Designer (using the "edit" button in the Slots\Signals dialog).
I added the overriding definition of the signal to the class header file.
How do I proceed? Does the signal function has to have a body and if so what does it contain?
The Qt assistant documentation is very lacking.
Thank you.
Re: Create new signal for derived widget
Worked out a solution.
Connected the original signal stateChanged(int) to slot animateClick(int).
In the slot definition (.cpp) I emit my overridden signal using:
Code:
void QCheckBoxCustom::animateClick(int state)
{
emit stateChanged(index, state); //index is a class data member
}
Is there another way?
Re: Create new signal for derived widget
You may be interested in QSignalMapper.
Re: Create new signal for derived widget
Okay, didn't know about that.
Thank you.