Qt Forum

    • Login
    • Search
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Unsolved

    Call for Presentations - Qt World Summit

    Best way to transfer data between two threads ?

    QML and Qt Quick
    2
    2
    1507
    Loading More Posts
    • 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.
    • G
      gaganbm last edited by

      Hi,

      I have a main GUI thread and a separate thread for network connectivity and reading data from TCP Socket.

      The data read from the TCPSocket is to be sent to the main GUI thread for further processing. What is the best way to achieve this ?

      Should I use a shared buffer or a queued signal-slot connection is optimal ?
      (The TCPSocket data are expected to come pretty frequently.)

      Thanks

      1 Reply Last reply Reply Quote 0
      • JKSH
        JKSH Moderators last edited by

        Hi,

        You don't need a separate thread for networking.

        Just use the QTcpSocket's asynchronous API: connect the readyRead() signal to a slot that reads and processes the data. Your GUI will remain responsive.

        Qt Doc Search for browsers: forum.qt.io/topic/35616/web-browser-extension-for-improved-doc-searches

        1 Reply Last reply Reply Quote 0
        • First post
          Last post