To understand the issue you have to understand how signals are emitted:
They are simply a non-static member function call and thus require an instance to be called on (the “sender”). Typically, this instance is this
(if you emit the signal from within another non-static member function of the same class), so the call syntax becomes a normal function call without any (literal) instance. The emit
keyword is optional and is simply a macro which expands to nothing. The following four versions are all the same when written in a member function of the same class which contains the signal:
emit this->signalLogAppend("foo");
emit signalLogAppend("foo");
this->signalLogAppend("foo");
signalLogAppend("foo");
If you emit the signal of the outer class from within the inner class, the this
pointer refers to an instance of the inner class and thus there is some instance missing for the outer class. It’s the same like if you call any other function of the outer class from within the inner class: the compiler doesn’t know on which object instance (of the outer class) to call it on. So you have to write something like:
emit someLogWriter->signalLogAppend("foo");
Here, someLogWriter
is the instance of LogWriter
for which you want to emit the signal.