tags:

views:

300

answers:

3

can qt signals be public or private?

Can I create internal signals, which are seen only inside the class?

added: I have a class with some internal signals. How can I make those signals invisible for other classes (encapsulation & information hiding)

thanks in advance, anton

+1  A: 

Qt signals are public in the sense that any object can connect to any signal.

Kyle Lutz
A: 

No. Signals cannot be public or private. Qt signals are protected class methods.

"signals" keyword is defined in qobjectdefs.h (line 69 as for Qt 4.6.1):

#   define signals protected
Andrei Vlasyuk
+1  A: 

Slots are simple methods which can be public, protected, or private.

As Andrei pointed it out, signal are only a redefinition of protected, meaning they can only be emitted by the class in which they are defined.

If you want to make a class emit a signal from anoter one, you have to add it a public method (or slot) like this one:

void emitTheSignal(...) {
  emit theSignal(...);
}
gregseth