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 make the slot runs in receive thread?

How to make the slot runs in receive thread?

Scheduled Pinned Locked Moved General and Desktop
2 Posts 2 Posters 1.8k 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
    kevinm
    wrote on last edited by
    #1

    Hi all,

    I have many TCPSocketThread to connect with users, and DataHandlerThread to deal with the data received from TCPSocketThread.
    There might be a lot of TCP connections, and each data transfer will affect database. So I implemented a Database ThreadPool to manage DataHandlerThreads.

    Look at this connect.
    @
    QObject::connect(pThread, SIGNAL(execFinished(TWorkThread*)), this, SLOT(dataDealFinishedEvent(TWorkThread*)));
    @
    pThread is DataHandlerThread. When this thread finished it's work, it should tell the socketThread it finished(execFinished), then this TCPSocketThread should return the DataHandlerThread to ThreadPool.

    As now, I can make the readyRead->dataReceivedEvent() work well, the TCPSocketThread::dataReceivedEvent now works in TCPSocketThread.

    In TCPSocketThread::dataReceivedEvent, I make that connect, anyway I debug, the triggerred thread are main thread or DataHandlerThread.(With Qt::DirectConnection, Qt::QueriedConnection)

    Are there any who can tell me how I can make the slot dataDealFinishedEvent runs in TCPSocketThread??

    Many thanks,
    Kevin

    Edit: code sections need to be wrapped in @ tags; Andre

    1 Reply Last reply
    0
    • G Offline
      G Offline
      giesbert
      wrote on last edited by
      #2

      is TCPSocketThread a subclas of QThread? If yes, the object itself belongs to the creating thread (typically the main thread), and the slot will be executed there. "Have a look at peppes article about threads.":http://developer.qt.nokia.com/wiki/ThreadsEventsQObjects

      Nokia Certified Qt Specialist.
      Programming Is Like Sex: One mistake and you have to support it for the rest of your life. (Michael Sinz)

      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