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 connect() function behave differently in movetothread

how connect() function behave differently in movetothread

Scheduled Pinned Locked Moved Unsolved General and Desktop
3 Posts 3 Posters 438 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.
  • J Offline
    J Offline
    JadeN001
    wrote on last edited by
    #1

    I used moveToThread() to move the worker object ,in which i'm doing setSocketDescripter, and I have connected two connection readyRead and disconnect in worker class. Rest of the connections are there in the server class. and the code is working fine.
    I have created a Qvector of QTcpSockets in server class which is global.
    Now if I move one connection from server class to the worker class, the size of the vector becomes zero.
    in worker class ::
    connect(this,SIGNAL(aboutToWrite(QByteArray, QTcpSocket *)),S,SLOT(messageFromclient(QByteArray, QTcpSocket *)));

    in server class::
    connect(worker,SIGNAL(aboutToWrite(QByteArray, QTcpSocket *)),this,SLOT(messageFromclient(QByteArray, QTcpSocket *)));

    in messageFromClient() slot , i'm sending messages to all the sockets connected but when I move this connection to worker class , the vector size becomes zero even if there are multiple clients connected.

    1 Reply Last reply
    0
    • M Offline
      M Offline
      MokJ
      wrote on last edited by
      #2

      I think the connection should be done outside the worker class , as worker class will only be called when its required.

      1 Reply Last reply
      0
      • SGaistS Offline
        SGaistS Offline
        SGaist
        Lifetime Qt Champion
        wrote on last edited by
        #3

        Hi,

        Can you show your actual code ?

        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
        1

        • Login

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