Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. QML and Qt Quick
  4. Can i use reference in signal slots
Forum Updated to NodeBB v4.3 + New Features

Can i use reference in signal slots

Scheduled Pinned Locked Moved QML and Qt Quick
14 Posts 4 Posters 4.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.
  • P Offline
    P Offline
    praneeth007
    wrote on last edited by
    #5

    It is creating two temporary memory addresses .
    So it will causes the time complexity problem.

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

      Well, you are using QueuedConnections, so don't be surprised.

      I still fail to see any problem here, possibly I am too dumb for this. Or maybe it's the weekend-brain ;-)

      (Z(:^

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

        Hi,

        If you use a queued connection, Qt will copy your signal arguments. You don't need to worry about memory management (unless your argument is a pointer).

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

        1 Reply Last reply
        0
        • P Offline
          P Offline
          praneeth007
          wrote on last edited by
          #8

          So is it good or bad using references in signal /slot

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

            [quote author="praneeth007" date="1405928051"]So is it good or bad using references in signal /slot [/quote]

            In case of most of non-QObject classes: it is good and recommended practice.

            (Z(:^

            1 Reply Last reply
            0
            • G Offline
              G Offline
              giesbert
              wrote on last edited by
              #10

              Just use const refernces. Qt makes it work :-)

              Nokia Certified Qt Specialist.
              Programming Is Like Sex: One mistake and you have to support it for the rest of your life. (Michael Sinz)

              1 Reply Last reply
              0
              • P Offline
                P Offline
                praneeth007
                wrote on last edited by
                #11

                why const compulsory

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

                  [quote author="praneeth007" date="1406010712"]why const compulsory [/quote]

                  Without it, you would keep modifying the original string.

                  (Z(:^

                  1 Reply Last reply
                  0
                  • P Offline
                    P Offline
                    praneeth007
                    wrote on last edited by
                    #13

                    I want to modify those

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

                      [quote author="praneeth007" date="1406016204"]I want to modify those[/quote]You can't do that through signals and slots.

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

                      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