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. Handle touch event and flicks simultaneously in Qml
Forum Updated to NodeBB v4.3 + New Features

Handle touch event and flicks simultaneously in Qml

Scheduled Pinned Locked Moved QML and Qt Quick
5 Posts 3 Posters 3.1k 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.
  • A Offline
    A Offline
    alan73
    wrote on last edited by
    #1

    I'm trying to write UI on Qml with two capabilities:

    1. handle touch event (to choose some object)

    2. handle flick events (to view some large object)

    It's my code:

    @Rectangle {
    width: 500; height: 500
    Flickable {
    anchors.fill: parent

        onContentXChanged: {
        console.log("x changed")
        //redraw large object
    
    MouseArea {
        anchors.fill: parent
        preventStealing: true
    
        onClicked: {
        console.log("clicked")
        //choose some object
        }
    }
    

    }@

    I have two problems:

    1. On Android clicked events don't appear (even with preventStealing property)

    2. How can I differ short touch (clicked) event from pressing+dragging+releasing? As I understand, MouseArea must send clicked event in both cases.

    1 Reply Last reply
    0
    • sierdzioS Offline
      sierdzioS Offline
      sierdzio
      Moderators
      wrote on last edited by
      #2

      You have missed setting contentHeight and contentWidth in your Flickable. That is probably why the MouseArea does not respond: it's size might be 0x0.

      (Z(:^

      1 Reply Last reply
      0
      • A Offline
        A Offline
        alan73
        wrote on last edited by
        #3

        With setting content width and height now I get mouse events but miss flicks :) Is there a way of combining MouseArea and Flickable?

        1 Reply Last reply
        0
        • sierdzioS Offline
          sierdzioS Offline
          sierdzio
          Moderators
          wrote on last edited by
          #4

          Yes, make your MouseArea smaller ;) After all, your selectable items will not occupy the whole content area?

          Also, you might consider using this to pass the even to the Flickable:
          @
          MouseArea {
          anchors.fill: parent
          preventStealing: true

              onClicked: {
                console.log("clicked")
                mouse.accepted = false
                // or: event.accepted = false
              }
          }
          

          @

          (Z(:^

          1 Reply Last reply
          0
          • A Offline
            A Offline
            aabc
            wrote on last edited by
            #5

            I also noticed Qt have problems with detecting touch events from multiple sources

            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