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. Read data from GUI in thread
Qt 6.11 is out! See what's new in the release blog

Read data from GUI in thread

Scheduled Pinned Locked Moved General and Desktop
4 Posts 2 Posters 1.4k 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.
  • V Offline
    V Offline
    vlad0922
    wrote on last edited by
    #1

    Hello!

    I have vectors and i need to fill it depending on user input.
    Vectors are large so i want to split computation in some threads, so i need to read data from GUI in those threads and return vector when task will be done.

    How i can do it?
    Thank you in advance!

    1 Reply Last reply
    0
    • F Offline
      F Offline
      frankiefrank
      wrote on last edited by
      #2

      Have you considered signals and slots? If your thread is running an event loop (exec()) you can connect a signal from the main GUI thread to a slot on the processing thread, and emit a signal from that thread when task is done.

      "Roads? Where we're going, we don't need roads."

      1 Reply Last reply
      0
      • V Offline
        V Offline
        vlad0922
        wrote on last edited by
        #3

        I can return data with emitted signal, but how can i read it from UI?

        1 Reply Last reply
        0
        • F Offline
          F Offline
          frankiefrank
          wrote on last edited by
          #4

          You could emit a signal from the worker thread, handle it in the slot in the main UI thread, get your input data from there, and then emit a signal to be handled in the worker thread and continue processing there.

          "Roads? Where we're going, we don't need roads."

          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