Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. Mobile and Embedded
  4. Get SwipeView gesture
Qt 6.11 is out! See what's new in the release blog

Get SwipeView gesture

Scheduled Pinned Locked Moved Unsolved Mobile and Embedded
1 Posts 1 Posters 497 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.
  • F Offline
    F Offline
    Flavian
    wrote on last edited by
    #1

    Hello,

    I have the following problem. I have 3 pages in a swipeView and I want to catch a swipe Gesture when I am on the first page (and when I make a swipe to go to page -1 - which doesn't exists ) and to interpret this gesture and do something else with (like opening a left menu on mobile)

    I did't know how to extract it from a swipeView, so I basically put a MauseArea like this:

     MouseArea {
            id: temporary_swipe_
            anchors.fill: parent
            property point origin
            property bool ready: false
            signal move(int x, int y)
            signal swipe(string direction)
            propagateComposedEvents: true
    
            onMove: {
            console.log("******************I just moved x= ", x, "      y=",y)
            }
            onSwipe: {
            console.log("******************I just swiped= ", direction)
            }
    
            onPressed: {
                console.log("**********************am intrat pe aici: onPressed")
                drag.axis = Drag.XAndYAxis
                origin = Qt.point(mouse.x, mouse.y)
                mouse.accepted = false;
            }
    
            onPositionChanged: {
                console.log("**********************am intrat pe aici: Position CHanged")
                switch (drag.axis) {
                case Drag.XAndYAxis:
                    if (Math.abs(mouse.x - origin.x) > 16) {
                        drag.axis = Drag.XAxis
                    }
                    else if (Math.abs(mouse.y - origin.y) > 16) {
                        drag.axis = Drag.YAxis
                    }
                    break
                case Drag.XAxis:
                    move(mouse.x - origin.x, 0)
                    break
                case Drag.YAxis:
                    move(0, mouse.y - origin.y)
                    break
                }
                //mouse.accepted = false;
            }
    
            onReleased: {
                console.log("**********************am intrat pe aici: onReleased")
                switch (drag.axis) {
                case Drag.XAndYAxis:
                    canceled(mouse)
                    break
                case Drag.XAxis:
                    swipe(mouse.x - origin.x < 0 ? "left" : "right")
                    break
                case Drag.YAxis:
                    swipe(mouse.y - origin.y < 0 ? "up" : "down")
                    break
                }
                mouse.accepted = false;
            }
        }
    

    I used mouse.accepted to pass the event lower, but the problem is: if onPressed gets "mouse.accepted = false;", then the onReleased and onPositionChanged never gets triggered.

    Otherwise, if onPressed gets consumend, I can't do the regular stuff in my original SwipeView.

    Has anyone tried to achieve something similar?

    With best regards.
    Flavian

    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