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
Forum Updated to NodeBB v4.3 + New Features

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 447 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 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?

    Christian EhrlicherC 1 Reply Last reply
    0
    • G glamis

      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?

      Christian EhrlicherC Offline
      Christian EhrlicherC Offline
      Christian Ehrlicher
      Lifetime Qt Champion
      wrote on 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
      0
      • Christian EhrlicherC Christian Ehrlicher

        @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 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?

        Christian EhrlicherC 1 Reply Last reply
        0
        • G glamis

          @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?

          Christian EhrlicherC Offline
          Christian EhrlicherC Offline
          Christian Ehrlicher
          Lifetime Qt Champion
          wrote on 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

          • Login

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