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. How to use the connect
Forum Update on Monday, May 27th 2025

How to use the connect

Scheduled Pinned Locked Moved Unsolved General and Desktop
threadconnect
3 Posts 3 Posters 417 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 am having a problem with my proyect, the program it is simple, I want to recieve a QString from a thread and add it to the QListWidget, but doesnt work the connect function.

    ERROR: no matching function for call to 'MainWindow::connect(hiloDelSocket*&, void (hiloDelSocket::)(QString), QListWidget&, <unresolved overloaded function type>)'

    hilo = new hiloDelSocket(this);
    connect(hilo, &hiloDelSocket::datos, ui->lista, &QListWidget::addItem);
    
    //thread
    void hiloDelSocket::run(){
        ZeroMemory(buffer,12);
        recv(sock,buffer,12,0);
        QString a = buffer;
        emit datos(a);
    }
    
    //header
    class hiloDelSocket: public QThread
    {
    public:
        hiloDelSocket(QObject *parent = nullptr);
    
    signals:
        void datos(const QString);
    
    protected:
        void run() override;
    
    private:
        char buffer[12];
        SOCKET sock;
    
    };
    
    jsulmJ J.HilkJ 2 Replies Last reply
    0
    • J JuanNunez

      Hello, I am having a problem with my proyect, the program it is simple, I want to recieve a QString from a thread and add it to the QListWidget, but doesnt work the connect function.

      ERROR: no matching function for call to 'MainWindow::connect(hiloDelSocket*&, void (hiloDelSocket::)(QString), QListWidget&, <unresolved overloaded function type>)'

      hilo = new hiloDelSocket(this);
      connect(hilo, &hiloDelSocket::datos, ui->lista, &QListWidget::addItem);
      
      //thread
      void hiloDelSocket::run(){
          ZeroMemory(buffer,12);
          recv(sock,buffer,12,0);
          QString a = buffer;
          emit datos(a);
      }
      
      //header
      class hiloDelSocket: public QThread
      {
      public:
          hiloDelSocket(QObject *parent = nullptr);
      
      signals:
          void datos(const QString);
      
      protected:
          void run() override;
      
      private:
          char buffer[12];
          SOCKET sock;
      
      };
      
      jsulmJ Offline
      jsulmJ Offline
      jsulm
      Lifetime Qt Champion
      wrote on last edited by
      #2

      @JuanNunez There are two versions of addItem, you need to tell connect which to use.

      Try:

      connect(hilo, &hiloDelSocket::datos, ui->lista, QOverload<QString>::of(&QListWidget::addItem));
      

      https://forum.qt.io/topic/113070/qt-code-of-conduct

      1 Reply Last reply
      2
      • J JuanNunez

        Hello, I am having a problem with my proyect, the program it is simple, I want to recieve a QString from a thread and add it to the QListWidget, but doesnt work the connect function.

        ERROR: no matching function for call to 'MainWindow::connect(hiloDelSocket*&, void (hiloDelSocket::)(QString), QListWidget&, <unresolved overloaded function type>)'

        hilo = new hiloDelSocket(this);
        connect(hilo, &hiloDelSocket::datos, ui->lista, &QListWidget::addItem);
        
        //thread
        void hiloDelSocket::run(){
            ZeroMemory(buffer,12);
            recv(sock,buffer,12,0);
            QString a = buffer;
            emit datos(a);
        }
        
        //header
        class hiloDelSocket: public QThread
        {
        public:
            hiloDelSocket(QObject *parent = nullptr);
        
        signals:
            void datos(const QString);
        
        protected:
            void run() override;
        
        private:
            char buffer[12];
            SOCKET sock;
        
        };
        
        J.HilkJ Offline
        J.HilkJ Offline
        J.Hilk
        Moderators
        wrote on last edited by J.Hilk
        #3

        @JuanNunez said in How to use the connect:

        unresolved overloaded function type

        addItem has multiple overloads and the connect cont resolve which one to use.

        https://doc.qt.io/qt-5/qtglobal.html#qOverload

        also don't use threads. I'm 90% sure you don't know what your doing, and don't need them in the first place


        Be aware of the Qt Code of Conduct, when posting : https://forum.qt.io/topic/113070/qt-code-of-conduct


        Q: What's that?
        A: It's blue light.
        Q: What does it do?
        A: It turns blue.

        1 Reply Last reply
        2

        • Login

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