Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Separate the code from GUI thread
Forum Updated to NodeBB v4.3 + New Features

Separate the code from GUI thread

Scheduled Pinned Locked Moved General and Desktop
2 Posts 2 Posters 1.3k Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • S Offline
    S Offline
    saam_6066
    wrote on last edited by
    #1

    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.

    1 Reply Last reply
    0
    • K Offline
      K Offline
      KA51O
      wrote on last edited by
      #2

      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]

      1 Reply Last reply
      0

      • Login

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • Users
      • Groups
      • Search
      • Get Qt Extensions
      • Unsolved