Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

private/public qt signals

Tags:

qt

qt-signals

Can Qt signals be public or private? Can I create internal signals, which are seen only inside the class?

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

like image 314
anton Avatar asked Jan 26 '10 22:01

anton


People also ask

Are signals public Qt?

Signals are public access functions and can be emitted from anywhere, but we recommend to only emit them from the class that defines the signal and its subclasses.

What are Qt Public slots?

In C++, public means those members that are accessible from anywhere where the object is visible, private means that members are accessible only from within other members of the same class or from their friends. But in Qt, the difference in private slots and public slots seem not to exist.

How do Qt signals work?

The Qt signals/slots and property system are based on the ability to introspect the objects at runtime. Introspection means being able to list the methods and properties of an object and have all kinds of information about them such as the type of their arguments.

Can slots be private Qt?

there is no harm with using slot as a private member, if you are making use of those slots within the same class. it is just a normal member function there is nothing more than normal function... but if you want use those slot outside of the class then you should declare as a public slots.


1 Answers

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 

UPDATE: signals are only protected upto and including all minor versions of Qt 4. From Qt 5.0 onwards they are public. See https://stackoverflow.com/a/19130831.

like image 166
Andrei Vlasyuk Avatar answered Sep 26 '22 17:09

Andrei Vlasyuk