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. is custom Struct used as param of connect efficient? pass by value, not pointer, because signal and slot are not in the same thread
Forum Updated to NodeBB v4.3 + New Features

is custom Struct used as param of connect efficient? pass by value, not pointer, because signal and slot are not in the same thread

Scheduled Pinned Locked Moved Unsolved General and Desktop
5 Posts 3 Posters 547 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.
  • O Offline
    O Offline
    opengpu
    wrote on last edited by aha_1980
    #1

    is custom Struct used as param of connect effiecnt?pass by value, not pointer, because signal and slot are not in the same thread

    1 Reply Last reply
    0
    • sierdzioS Offline
      sierdzioS Offline
      sierdzio
      Moderators
      wrote on last edited by
      #2

      Yes, why not? Unless it is some huge behemoth, CPU will handle parameter copying without an issue.

      (Z(:^

      1 Reply Last reply
      4
      • SGaistS Offline
        SGaistS Offline
        SGaist
        Lifetime Qt Champion
        wrote on last edited by
        #3

        Hi,

        Depending on its content and use you can make it implicitly shared using QSharedDataPointer and thus make the "read only" copy faster.

        Interested in AI ? www.idiap.ch
        Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

        O 1 Reply Last reply
        2
        • SGaistS SGaist

          Hi,

          Depending on its content and use you can make it implicitly shared using QSharedDataPointer and thus make the "read only" copy faster.

          O Offline
          O Offline
          opengpu
          wrote on last edited by opengpu
          #4

          @SGaist actually the non-mainThread is respond for get the data from the internet, and mainThread is read the data and show it in Qt-ui.
          so QSharedDataPointer is much faster and precice than pass-by value?

          why QMetaObject::invokeMethod pass custom-type called Twice custom-type's copy constructor...
          https://forum.qt.io/topic/102915/qmetaobject-invokemethod-pass-custom-type-called-twice-custom-type-s-copy-constructor

          1 Reply Last reply
          0
          • SGaistS Offline
            SGaistS Offline
            SGaist
            Lifetime Qt Champion
            wrote on last edited by
            #5

            As already written by @sierdzio, it's about the size of your object. If speed is that critical for you, then benchmark your code.

            Interested in AI ? www.idiap.ch
            Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

            1 Reply Last reply
            2

            • Login

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