Qt World Summit: Register Today!

In MouseArea.onEntered, detect if the cause is only that the *MouseArea* moved and came to be under the cursor

  • In MouseArea.onEntered, can I detect if the cause for the event firing is only that the MouseArea moved and came to be under the cursor, rather than the other way round?

    I thought of doing something like this: (pseudocode)

        MouseArea {
            // ...
            property bool positionDirty = false
            Connections {
                target: window
                onAfterRendering: {
                    positionDirty = false;
            onMouseAreaPosChanged: {
                positionDirty = true;
            onEntered: {
                if(positionDirty) {
                    positionDirty = false;
                // handle event here

    But this makes the assumption that entered will be fired after mouseAreaPosChanged, and before window.afterRendering. And I'm not confident in that assumption.

    Also, it doesn't work when an ancestor of the MouseArea moves, or when the MouseArea is positioned/sized via anchoring.

Log in to reply