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. [solved] linking error when setting up signals and slots within a thread
Forum Updated to NodeBB v4.3 + New Features

[solved] linking error when setting up signals and slots within a thread

Scheduled Pinned Locked Moved General and Desktop
4 Posts 2 Posters 924 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.
  • K Offline
    K Offline
    kpks
    wrote on 12 Jan 2014, 01:20 last edited by
    #1

    Hello,

    I have a tcpServer class calling a thread when there is an incoming connection; The thread in-turn creates a tcpSocket and waits for data. I want the data to be analyzed/plotted. I tried setting up a signal on readyread connection to a slot defined in the thread.
    @void listenWriteThread::run()
    {
    QTcpSocket tcpSocket;
    if (!tcpSocket.setSocketDescriptor(socketDescriptor)) {
    emit error(tcpSocket.error());
    return;
    }

    connect(tcpSocket,SIGNAL(readyRead()),this,SLOT(analyzeThis()));@
    

    I get a No-matching function error:
    D:\kpks\software\tcpComm\listenWriteThread.cpp:18: error: no matching function for call to 'listenWriteThread::connect(QTcpSocket&, const char*, listenWriteThread* const, const char*)'
    connect(tcpSocket,SIGNAL(tcpSocket.readyRead()),this,SLOT(analyzeThis()));

    What am I doing wrong here?

    Thanks and Regards,
    kpks

                                                                             ^
    
    1 Reply Last reply
    0
    • K Offline
      K Offline
      kpks
      wrote on 12 Jan 2014, 02:05 last edited by
      #2

      Sorry! That was atrocious doubt! I just forgot to make tcpSocket a pointer :(

      I changed my thread definition to have socket as a pointer:

      @class listenWriteThread : public QThread
      {
      Q_OBJECT

      public:
      listenWriteThread(int socketDescriptor, const QString &fortune, QObject *parent);

      void run();
      

      public slots:
      void analyzeThis();
      signals:
      void error(QTcpSocket::SocketError socketError);

      private:
      QTcpSocket* tcpSocket;
      int socketDescriptor;
      QString text;
      };@

      1 Reply Last reply
      0
      • K Offline
        K Offline
        kpks
        wrote on 12 Jan 2014, 02:06 last edited by
        #3

        I have a new problem though, the connection is fine and my C client is sending data every 100ms but qt does nothing! My qt application is tcpComm.exe

        Then I get a windows error saying
        "the tcpCOmm.exe has encountered a problem and needs to close "

        Should I make this a separate thread?

        1 Reply Last reply
        0
        • S Offline
          S Offline
          SGaist
          Lifetime Qt Champion
          wrote on 12 Jan 2014, 21:23 last edited by
          #4

          Hi,

          Did you initialize tcpSocket properly ? Did you update your run function ?

          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

          2/4

          12 Jan 2014, 02:05

          • Login

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