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. Detect movement inside an Item
Forum Updated to NodeBB v4.3 + New Features

Detect movement inside an Item

Scheduled Pinned Locked Moved QML and Qt Quick
4 Posts 2 Posters 1.0k 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.
  • O Offline
    O Offline
    ondrejandrej
    wrote on last edited by
    #1

    Hello,

    I have a ComboBox-like element, which has a drop down menu. The drop down menu is created as a child of the main window, with coordinates of my element. When the element moves and drop-down is currently open, the position of the drop-down menu is not updated. I'd like to close it in this case.

    So how do I detect movement of my QML element? It can be due to scrolling (when the element is on a Flickable) or adding/removing other children in a Row, Column, etc.

    If you have any other idea to make a drop-down menu (rather than creating it as a child of top-level Item), it's also appreciated.

    1 Reply Last reply
    0
    • dheerendraD Offline
      dheerendraD Offline
      dheerendra
      Qt Champions 2022
      wrote on last edited by
      #2

      Every property in QML as onChanged<PropertyName> signal handler. See whether this can help you.

      Dheerendra
      @Community Service
      Certified Qt Specialist
      http://www.pthinks.com

      1 Reply Last reply
      0
      • O Offline
        O Offline
        ondrejandrej
        wrote on last edited by
        #3

        It's on<PropertyName>Changed.

        So which property do you suggest that I observe?

        1 Reply Last reply
        0
        • O Offline
          O Offline
          ondrejandrej
          wrote on last edited by
          #4

          What I need is actually to detect changes in the data returned by myItem.mapToItem(mainWindow.contentItem, 0, 0).
          I could periodically call this function in a QTimer and compare returned objects, but that's a really ugly solution. Better one would be to call mapToItem() in a signal handler.

          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