Use of undeclared identifier 'connect'
Solved
Qt 6
-
Hi, I am having this error but having no clue of what causes it. I have two classes that inherits from QDialog and I try to connect them in the main.cpp. What I want to do here is simply that when a mouse is pressed in window dialog, it will triggers the receiverWindow to change the displayed text.
connect(&w, &window::mousePressEvent, &receiverWindow, &Receiver::text);
/*They are the errors that I receive*/ QObject::connect: signal not found in window Use of undeclared identifier 'connect'
-
Two things here:
connect
is a member ofQObject
, so if you're using it outside of that class, e.g. in themain()
function you need to fully qualify it asQObject::connect
.mousePressEvent
is, as the name suggests, an event, not a signal, so you can't use it in connect statement as such. -
@Chris-Kawa Thank you for point them out to me.