Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct
Separate the code from GUI thread
saam_6066 last edited by
I'm new with threading in qt and I want to know how I can separate a class from main thread and run it on the worker thread? My class is derived from QGraphicsScene and it's main job is to provide information for GUI like if an item is selected or deleted from the scene. so it is basically a connection between the graphics stuff and my code. GUI and this class are connected via signal and slots connections.
Thanks for your help.
KA51O last edited by
There are general examples in the "QThread documentation":http://qt-project.org/doc/qt-4.8/qthread.html and there's also an "article about the general use of QThread":http://qt-project.org/wiki/QThreads_general_usage.
BUT you are not allowed to access, change or create GUI related object in another thread then the main thread. I'm not sure if this also includes QGraphicsScene, but the name kind of suggests this.
Quote from the QThread documentation:
[quote]Note: It is not possible to change the thread affinity of GUI objects; they must remain in the main thread.[/quote]