![]() ![]() But I want to update my GUI from worker thread.How can this be possible. The best way to do this, I think, is use QThread instead of posix thread, and use Qt signals for communicating between threads. Based on user (GUI) input, it creates objects that are following the observer pattern (the objects subscribe to updates from observable data objects.) Upon getting some of these updates, there might be a workload these objects need to complete. I know GUI cant be updated from worker thread but only by main/GUI thread using signal and slots. main.C Here we define the time-consuming operation. This example consists of the following codes: main.C, userdef.h, window.C and window.h. This example makes uses QtConcurrent::run(), QFuture and QFutureWatcher, rather than just a QThread. ![]() That's why the proper way to do this is to notify main thread from worker, and the code in main thread will actually update text box, progress bar or something else. When the thread finishes running, a message appears on the screen. Dont use pixmaps or drawing to the GUI from a thread that is. Threads Conventional GUI applications have. Qt event loop feature overview C++ GUI Programming with Qt4: Multithreading. Can QWidget::update() be called in a sub thread other than the GUI thread. QT UPDATE GUI FROM WORKER THREAD HOW TOImportant thing about Qt is that you must work with Qt GUI only from GUI thread, that is main thread. Several good books describe how to work with Qt threads. ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |