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. Pass item into signal as an argument.
Qt 6.11 is out! See what's new in the release blog

Pass item into signal as an argument.

Scheduled Pinned Locked Moved QML and Qt Quick
3 Posts 2 Posters 1.1k 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.
  • M Offline
    M Offline
    maksim1979
    wrote on last edited by
    #1

    Hi

    I've got something like that:

    @Item {
    id: root

    signal dragging(variant item, point mousePosition)
    

    ...

    MouseArea {
    ...
    onPositionChanged: {
    root.dragging(root, Qt.point(mouseX, mouseY));
    }
    }
    }
    @

    So, here is my question, in your opinion is it a good idea to pass the item itself into a signal, or would be better to introduce some kind of uuid(a primitive type) for items and pass them?

    Thanks a lot,
    Maksim

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

      QML does not copy the object when sending, all it's doing is to send the object ID (or memory address, I don't remember atm). So there is no need to devise any custom UUID scheme: it's already there.

      (Z(:^

      1 Reply Last reply
      0
      • M Offline
        M Offline
        maksim1979
        wrote on last edited by
        #3

        Sierdzio, thanks a lot!!!

        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