With Qt you don't really have to deal with unexpected messages. A signal is triggered by an event, like a button click or a slider value changing, a checkbox being toggled, this kind of thing. A slot is just a place to receive it, it's a regular function or method with a compatible signature for the kind of event it's meant to process. There are no unexpected calls because you have to explicitly
connect a signal to a slot, something like:
QObject::connect(&button, &QPushButton::clicked,
&mainWindowController, &MainWindowController::onButtonClicked);
If no slot is connected, the signal just doesn't go anywhere.
Something that's special with Qt is that signals and slots are declared in the class using custom syntax, e.g.
slots:
void onValueChanged(int value);
signals:
void valueChanged(int newValue);
Yes here "signals:" and "slots:"
look like the same kind of keyword as "public:" or "private:" in a class declaration, even though internally they're #defined as "public:" and "/**/" respectively.
Qt makes use of a tool called MOC – the Meta Object Compiler – to generate code for signals and slots. It's not a pre-processor but a code generator, which has to run before you can actually compile the code. I think you could probably implement a similar system of event subscriptions without this additional code generation step.
See this page for details: https://woboq.com/blog/how-qt-signals-slots-work.html