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. Accessing QObject property from a non QObject subclass in another thread

Accessing QObject property from a non QObject subclass in another thread

Scheduled Pinned Locked Moved Unsolved General and Desktop
qml to c++multithreadqobject
4 Posts 2 Posters 406 Views
  • 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.
  • G Offline
    G Offline
    glamis
    wrote on 23 Feb 2024, 05:19 last edited by
    #1

    I have use case where I want to read properties of a QObject from a non QObject subclass (so no signals and slots) that is in another thread (non Qt thread).
    I got the instance of the QObject form the class by using its object name property and using the find Child class from the root object.
    Is it safe to do so? Are these methods reentrant?

    C 1 Reply Last reply 23 Feb 2024, 05:25
    0
    • G glamis
      23 Feb 2024, 05:19

      I have use case where I want to read properties of a QObject from a non QObject subclass (so no signals and slots) that is in another thread (non Qt thread).
      I got the instance of the QObject form the class by using its object name property and using the find Child class from the root object.
      Is it safe to do so? Are these methods reentrant?

      C Offline
      C Offline
      Christian Ehrlicher
      Lifetime Qt Champion
      wrote on 23 Feb 2024, 05:25 last edited by
      #2

      @glamis When a function is thread safe or reentrant then the documentation will tell you. Otherwise you have to assume it is not.

      Qt Online Installer direct download: https://download.qt.io/official_releases/online_installers/
      Visit the Qt Academy at https://academy.qt.io/catalog

      G 1 Reply Last reply 23 Feb 2024, 06:40
      0
      • C Christian Ehrlicher
        23 Feb 2024, 05:25

        @glamis When a function is thread safe or reentrant then the documentation will tell you. Otherwise you have to assume it is not.

        G Offline
        G Offline
        glamis
        wrote on 23 Feb 2024, 06:40 last edited by
        #3

        @Christian-Ehrlicher thanks for your response, in that case is the right way do so is to call the non thread safe methods in the context of the callee and use a QConcurrent run in the caller side?

        C 1 Reply Last reply 23 Feb 2024, 06:48
        0
        • G glamis
          23 Feb 2024, 06:40

          @Christian-Ehrlicher thanks for your response, in that case is the right way do so is to call the non thread safe methods in the context of the callee and use a QConcurrent run in the caller side?

          C Offline
          C Offline
          Christian Ehrlicher
          Lifetime Qt Champion
          wrote on 23 Feb 2024, 06:48 last edited by
          #4

          I would do so, yes. Even though I would not expect a threading problem with qFindChild as long as the object tree is not changing but one never knows.

          Qt Online Installer direct download: https://download.qt.io/official_releases/online_installers/
          Visit the Qt Academy at https://academy.qt.io/catalog

          1 Reply Last reply
          0

          1/4

          23 Feb 2024, 05:19

          • Login

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