Connect overloaded signals to overloaded slots
-
I have two signals:
void write(int address, QString type, QVariant value, bool ws); void write(int address, QVariant value);
and in another class the two related slots:
void modbus_write(int address, QString type, QVariant value, bool ws); void modbus_write(int address, QVariant value);
I want to connect each signal to its slot. I tried:
connect(&manager, QOverload<int, QVariant>::of(&Manager::write), this, QOverload<int, QVariant>::of(&Engine::modbus_write)); connect(&manager, QOverload<int, QString, QVariant, bool>::of(&Manager::write), this, QOverload<int, QString, QVariant, bool>::of(&Engine::modbus_write));
but the compiler says:
Invalid use of incomplete type 'class QVariant'
referred to the moc_ file.
In my class I put at the top:#include <QVariant>
What is the right syntax here?
-
@Mark81 said in Connect overloaded signals to overloaded slots:
#include <QVariant>
did you include that in the headers of the emitter and receiver?
-
@VRonin said in Connect overloaded signals to overloaded slots:
The connect doesn't match...
QOverload<int, QVariant>::of(&Engine::writeModbus)
?Yep, this was actually a typo due to the launch break :) I didn't recall the actual name and made a mess.
-
@J-Hilk said in Connect overloaded signals to overloaded slots:
did you include that in the headers of the emitter and receiver?
Got it!
It's weird because usually it tells me the exact file where the include is missing. This time it talked about the moc_ file and because I was unsure about the syntax I forgot to check it.