Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. undefined reference on emit function
QtWS25 Last Chance

undefined reference on emit function

Scheduled Pinned Locked Moved Unsolved General and Desktop
threademit signalconnect
4 Posts 3 Posters 579 Views
  • 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.
  • J Offline
    J Offline
    JuanNunez
    wrote on last edited by
    #1

    Hello, I have a proyect with a thread and a listWidget, the problem is when I use emit, the error is: "undefined reference to `hiloDelSocket::datos(QString)'", but I declered it on the header.

    void hiloDelSocket::run(){
        ZeroMemory(buffer,12);
        recv(sock,buffer,12,0);
        const QString a = buffer;
        emit datos(a); //error
    }
    
    //header
    class hiloDelSocket: public QThread
    {
    
        Q_OBJECT //I have to use it because otherwise it gives me other error
    
    public:
        hiloDelSocket(QObject *parent = nullptr);
    
    signals:
        void datos(const QString); //here is declarated
    
    protected:
        void run() override;
    
    private:
        char buffer[12];
        SOCKET sock;
    
    };
    
    jsulmJ 2 Replies Last reply
    0
    • J JuanNunez

      Hello, I have a proyect with a thread and a listWidget, the problem is when I use emit, the error is: "undefined reference to `hiloDelSocket::datos(QString)'", but I declered it on the header.

      void hiloDelSocket::run(){
          ZeroMemory(buffer,12);
          recv(sock,buffer,12,0);
          const QString a = buffer;
          emit datos(a); //error
      }
      
      //header
      class hiloDelSocket: public QThread
      {
      
          Q_OBJECT //I have to use it because otherwise it gives me other error
      
      public:
          hiloDelSocket(QObject *parent = nullptr);
      
      signals:
          void datos(const QString); //here is declarated
      
      protected:
          void run() override;
      
      private:
          char buffer[12];
          SOCKET sock;
      
      };
      
      jsulmJ Offline
      jsulmJ Offline
      jsulm
      Lifetime Qt Champion
      wrote on last edited by
      #2
      This post is deleted!
      1 Reply Last reply
      0
      • SGaistS Offline
        SGaistS Offline
        SGaist
        Lifetime Qt Champion
        wrote on last edited by
        #3

        Hi,

        The usual signature of the such a signal is rather a const reference and not a const object.

        Interested in AI ? www.idiap.ch
        Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

        1 Reply Last reply
        0
        • J JuanNunez

          Hello, I have a proyect with a thread and a listWidget, the problem is when I use emit, the error is: "undefined reference to `hiloDelSocket::datos(QString)'", but I declered it on the header.

          void hiloDelSocket::run(){
              ZeroMemory(buffer,12);
              recv(sock,buffer,12,0);
              const QString a = buffer;
              emit datos(a); //error
          }
          
          //header
          class hiloDelSocket: public QThread
          {
          
              Q_OBJECT //I have to use it because otherwise it gives me other error
          
          public:
              hiloDelSocket(QObject *parent = nullptr);
          
          signals:
              void datos(const QString); //here is declarated
          
          protected:
              void run() override;
          
          private:
              char buffer[12];
              SOCKET sock;
          
          };
          
          jsulmJ Offline
          jsulmJ Offline
          jsulm
          Lifetime Qt Champion
          wrote on last edited by
          #4

          @JuanNunez I deleted my first response as I did not realised that it was about a signal and one does not have to implement a signal.
          Did you try a complete rebuild after adding signal? Delete build folder, run qmake and build.

          1 Reply Last reply
          0

          • Login

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