Important: Please read the Qt Code of Conduct -

Separate the code from GUI thread

  • Hi,

    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.

  • There are general examples in the "QThread documentation": and there's also an "article about the general use of QThread":

    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]

Log in to reply