devxlogo

Signals and Public Slots Blocks

Signals and Public Slots Blocks

Question:
Everybody knows the meaning of public, private, and protected blocks in a class interface. While browsing through a KDE program I found two other block types: signals and public slots. What do they mean? Is this a special thing of Qt? If so, how do they make it possible?

Answer:
Qt isn’t C++, but a variant dialect called “moc” that defines three new keywords: signals, slots, and emit. Explaining the semantics and usage of these non-standard keywords is beyond the scope of this forum, but essentially, they are used in firing and handling events, and relating these events to a particular class and method. The Qt framework contains special header files to implement these extensions using the preprocessor.

devxblackblue

About Our Editorial Process

At DevX, we’re dedicated to tech entrepreneurship. Our team closely follows industry shifts, new products, AI breakthroughs, technology trends, and funding announcements. Articles undergo thorough editing to ensure accuracy and clarity, reflecting DevX’s style and supporting entrepreneurs in the tech sphere.

See our full editorial policy.

About Our Journalist