Read data from GUI in thread

  • 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!

  • 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.

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

  • 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.

Log in to reply

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.