Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

Use of undeclared identifier 'connect'



  • 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'
    

  • Moderators

    Two things here:

    connect is a member of QObject, so if you're using it outside of that class, e.g. in the main() function you need to fully qualify it as QObject::connect.

    mousePressEvent is, as the name suggests, an event, not a signal, so you can't use it in connect statement as such.


  • Moderators

    Two things here:

    connect is a member of QObject, so if you're using it outside of that class, e.g. in the main() function you need to fully qualify it as QObject::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.


Log in to reply