Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. General talk
  3. Qt 6
  4. Use of undeclared identifier 'connect'
Servers for Qt installer are currently down

Use of undeclared identifier 'connect'

Scheduled Pinned Locked Moved Solved Qt 6
3 Posts 2 Posters 4.5k Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • C Offline
    C Offline
    Christina123
    wrote on 3 Apr 2021, 20:16 last edited by
    #1

    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'
    
    1 Reply Last reply
    0
    • C Offline
      C Offline
      Chris Kawa
      Lifetime Qt Champion
      wrote on 3 Apr 2021, 20:26 last edited by
      #2

      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.

      C 1 Reply Last reply 3 Apr 2021, 20:48
      2
      • C Chris Kawa
        3 Apr 2021, 20:26

        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.

        C Offline
        C Offline
        Christina123
        wrote on 3 Apr 2021, 20:48 last edited by
        #3

        @Chris-Kawa Thank you for point them out to me.

        1 Reply Last reply
        0

        1/3

        3 Apr 2021, 20:16

        • Login

        • Login or register to search.
        1 out of 3
        • First post
          1/3
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • Users
        • Groups
        • Search
        • Get Qt Extensions
        • Unsolved