Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What exactly are signals and slots in Qt?

I know how they work conceptually, but how are signals and slots implemented in the Qt framework? Qt Creator treats them as keywords, but are they simply a set of macros, or is a special pre-processor required before these source files can be compiled?

In other words, if I use Qt's signal/slot features in my code, can I easily compile it on any C++ compiler?

like image 569
Tony the Pony Avatar asked Dec 23 '22 02:12

Tony the Pony


1 Answers

Many features of Qt, including signals, require preprocessing the source using the Qt Meta-Object Compiler (MOC).

If you use Qt's signals feature, you can compile your source code on any compiler and platform that is supported by Qt. If you need to compile on a platform not supported by Qt, you may be out of luck or at least in for a lot of fun integration work (this is true of any library or framework, of course).

If you are looking for a cross-platform signals implementation, you might also consider Boost.Signals.

like image 116
James McNellis Avatar answered Dec 28 '22 08:12

James McNellis