PDA

View Full Version : emit a signal



Morea
26th February 2006, 11:40
Just a quick one, if I wish to emit a signal from a specific object, I can do like this, right?

emit myObject->mySignal();

Update: There doesn't seem to be any way of making a signal public. Or is there?

jacek
26th February 2006, 13:14
You can connect some other signal to it:
connect( object1, SIGNAL( someSignal() ), object2, SIGNAL( someOtherSignal() ) );
Whenever object1 emits someSignal(), object2 will emit someOtherSignal().

Matt Smith
27th February 2006, 11:14
Just a quick one, if I wish to emit a signal from a specific object, I can do like this, right?

emit myObject->mySignal();

Update: There doesn't seem to be any way of making a signal public. Or is there?

Objects can only emit their own signals (including inherited ones), not others'. Signals are protected functions and when the compiler reads your headers, it reads "protected:" rather than "signals:"; short of altering the Qt source code itself, you can't change this. This is covered in "Practical Qt" on page 231.