Important: Please read the Qt Code of Conduct -

Detect movement inside an Item

  • 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.

  • Qt Champions 2017

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

  • It's on<PropertyName>Changed.

    So which property do you suggest that I observe?

  • 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.

Log in to reply