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. What is the meaning of Thread affinity?

What is the meaning of Thread affinity?

Scheduled Pinned Locked Moved General and Desktop
thread
3 Posts 2 Posters 4.3k Views 2 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.
  • H Offline
    H Offline
    Hareen Laks
    wrote on last edited by
    #1

    Hi,

    I'm reading the Qt Documentation and get stuck at thread affinity.

    http://doc.qt.io/qt-5/qobject.html#details

    Can anybody explain it to me?

    Thanks for reding this.

    1 Reply Last reply
    0
    • JKSHJ Offline
      JKSHJ Offline
      JKSH
      Moderators
      wrote on last edited by
      #2

      Hi @Hareen-Laks,

      When a signal is emitted, Qt will call the slot function. Qt needs to choose a thread to run the function.

      There are two ways to describe how Qt chooses the thread:

      • If the receiver QObject has an affinity for Thread B, then the slot function runs in Thread B.
      • If the receiver QObject lives in Thread B, then the slot function runs in Thread B.

      You can change the QObject's thread affinity by calling QObject::moveToThread().

      Qt Doc Search for browsers: forum.qt.io/topic/35616/web-browser-extension-for-improved-doc-searches

      H 1 Reply Last reply
      0
      • JKSHJ JKSH

        Hi @Hareen-Laks,

        When a signal is emitted, Qt will call the slot function. Qt needs to choose a thread to run the function.

        There are two ways to describe how Qt chooses the thread:

        • If the receiver QObject has an affinity for Thread B, then the slot function runs in Thread B.
        • If the receiver QObject lives in Thread B, then the slot function runs in Thread B.

        You can change the QObject's thread affinity by calling QObject::moveToThread().

        H Offline
        H Offline
        Hareen Laks
        wrote on last edited by
        #3

        @JKSH

        Thank you very much I think now I understood it. Thanks for the help.

        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