QThread Issues while creating GUI
-
wrote on 25 Aug 2024, 17:56 last edited by
I have created a GUI which utilises QTableview and the model gets set into the table for about 13k rows data of data.
To avoid the GUI to go into hang state, i added a Qthread based approach so that my database creation (which takes a lot of time) goes into the thread.But i would also like to update my other widgets inside that thread itself since they are also time consuming. How do i do that? I receive an error on this.
QObject: :cannot create children for a parent that is in a different thread.
Or is there any other way apart from QThread where i can avoid the problem of the GUI hanging whenever certain large computations /calculations happen in my GUI? -
Hi,
It's simple: don't do that. Never try to access GUI related elements from other threads than the main thread.
Use the worker object approach and signals and slots to communicate with the widgets.
2/2