Access to components of UI from the function of QtConcurrent::run(foo)
I want to access to components of UI (like as QLineEdit, QLabel, QTableView, etc) from the "foo" function in QtConcurrent::run(foo).
But I can
t, because the component must be static variable and I dont want.
How can I access to them?
Thanks a lot.
No, you can't because manipulating GUI element outside the main thread is not allowed. What you can do however is use signals and slots to communicate with the GUI stuff
Hi dear SGaist,
Thanks for your response.
I searched and most of uses said signal and slot must be used.
I implemented this approach but did not work! Because I can`t emit the signal from the thread (because signal function is not static).
How can I do that? May you give a simple code?
You can use a QObject wrapper class that will call the static function and then emit the signal needed
Can you give me a simple code example?
Wait, this might be a complication you don't need, did you took a look at the QFutureWatcher class ?