Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. General talk
  3. Qt 6
  4. Qt QML 6.2.1. How to identify the direction of the dragging event in MouseArea?
Forum Updated to NodeBB v4.3 + New Features

Qt QML 6.2.1. How to identify the direction of the dragging event in MouseArea?

Scheduled Pinned Locked Moved Solved Qt 6
2 Posts 1 Posters 423 Views
  • 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.
  • C Offline
    C Offline
    CuriousPan
    wrote on last edited by CuriousPan
    #1

    I'm using MouseArea and I'd like to identify whether user drags the mouse to the right or to the left. There's a signal
    positionChanged(MouseEvent mouse), but it neither provides information about the direction nor about the previous and current coordinates. Do you have any advices? Thank you in advance.

    1 Reply Last reply
    0
    • C Offline
      C Offline
      CuriousPan
      wrote on last edited by
      #2

      UPD.
      I found a solutions by myself. The only thing you need to do is to introduce a variable which stores a previous position of the cursor. Then you compare it with the current mouse X position each time mouse is moved (onPositionChanged()). If mouse X position is bigger, then this is a right move gesture. If mouse X position is smaller, then this is a left move gesture.
      Note: exclude 0 as it leads to undesired behaviour.
      Don't forget to update the variable storing the last cursor's position. From my experiece the difference would always be 1, 0 or -1 (we handled 0 case), because the signal is emitted each time the mouse moves (even on a signle pixel).

      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