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. Recognize arbitrary gestures in Qt5, like GestureArea in Qt4
Forum Updated to NodeBB v4.3 + New Features

Recognize arbitrary gestures in Qt5, like GestureArea in Qt4

Scheduled Pinned Locked Moved Unsolved QML and Qt Quick
9 Posts 3 Posters 3.9k 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.
  • K Offline
    K Offline
    kloffy
    wrote on last edited by kloffy
    #1

    Hi again! I have a custom subclass of QQuickItem that I would like to use in conjunction with MultiPointTouchArea. In particular, I would like to use the gesture recognition provided by MultiPointTouchArea, but have the events be handled by the subclass. Currently my QML is structured like this:

    MyCustomItem {
        id: myItem
        width: 800; height: 600
    
        MultiPointTouchArea {
            id: aTouchArea
            anchors.fill: parent
    
            minimumTouchPoints: 1
            maximumTouchPoints: 2
    
            onPressed: {
                console.log("pressed")
            }
            
            onReleased: {
                console.log("released")
            }
        }
    }
    

    That's all working well so far. However, I am wondering what is the best way to notify the parent of the events (in particular gestures) detected by the MultiPointTouchArea?

    Edit: Actually, I am beginning to think that MultiPointTouchArea might not be what I need in the first place. Essentially, my custom widget displays a graphical scene that I want to be able to pan and zoom using swipe and pinch gestures. I thought MultiPointTouchArea was a generic component that you could configure to detect arbitrary gestures, but it seems that is not the case. Really what I want is more like this:

    http://blog.qt.io/blog/2010/10/05/getting-in-touch-with-qt-quick-gestures-and-qml/

    However, it looks like that information is outdated.

    Edit: Changed title (from "Custom QQuickItem, receive events from MultiPointTouchArea") to reflect new information and better match the intent of the question.

    p3c0P 1 Reply Last reply
    0
    • K kloffy

      Hi again! I have a custom subclass of QQuickItem that I would like to use in conjunction with MultiPointTouchArea. In particular, I would like to use the gesture recognition provided by MultiPointTouchArea, but have the events be handled by the subclass. Currently my QML is structured like this:

      MyCustomItem {
          id: myItem
          width: 800; height: 600
      
          MultiPointTouchArea {
              id: aTouchArea
              anchors.fill: parent
      
              minimumTouchPoints: 1
              maximumTouchPoints: 2
      
              onPressed: {
                  console.log("pressed")
              }
              
              onReleased: {
                  console.log("released")
              }
          }
      }
      

      That's all working well so far. However, I am wondering what is the best way to notify the parent of the events (in particular gestures) detected by the MultiPointTouchArea?

      Edit: Actually, I am beginning to think that MultiPointTouchArea might not be what I need in the first place. Essentially, my custom widget displays a graphical scene that I want to be able to pan and zoom using swipe and pinch gestures. I thought MultiPointTouchArea was a generic component that you could configure to detect arbitrary gestures, but it seems that is not the case. Really what I want is more like this:

      http://blog.qt.io/blog/2010/10/05/getting-in-touch-with-qt-quick-gestures-and-qml/

      However, it looks like that information is outdated.

      Edit: Changed title (from "Custom QQuickItem, receive events from MultiPointTouchArea") to reflect new information and better match the intent of the question.

      p3c0P Offline
      p3c0P Offline
      p3c0
      Moderators
      wrote on last edited by
      #2

      Hi @kloffy
      Did you check PinchArea ?

      157

      K 1 Reply Last reply
      0
      • p3c0P p3c0

        Hi @kloffy
        Did you check PinchArea ?

        K Offline
        K Offline
        kloffy
        wrote on last edited by
        #3

        @p3c0 I already know that I will need further gestures in the future, so I was hoping for a generic solution that works with QGestureRecognizer, but perhaps PinchArea is the best choice for now. Thank you for the suggestion!

        p3c0P 1 Reply Last reply
        0
        • K kloffy

          @p3c0 I already know that I will need further gestures in the future, so I was hoping for a generic solution that works with QGestureRecognizer, but perhaps PinchArea is the best choice for now. Thank you for the suggestion!

          p3c0P Offline
          p3c0P Offline
          p3c0
          Moderators
          wrote on last edited by
          #4

          @kloffy You can have a look at some of its examples:
          http://doc.qt.io/qt-5/qtquick-demos-photosurface-example.html
          http://doc.qt.io/qt-5/qtquick-touchinteraction-pincharea-flickresize-qml.html

          157

          K 1 Reply Last reply
          0
          • p3c0P p3c0

            @kloffy You can have a look at some of its examples:
            http://doc.qt.io/qt-5/qtquick-demos-photosurface-example.html
            http://doc.qt.io/qt-5/qtquick-touchinteraction-pincharea-flickresize-qml.html

            K Offline
            K Offline
            kloffy
            wrote on last edited by kloffy
            #5

            @p3c0 Thank you! Yes, I did look at them, but it appears that PinchArea unfortunately has its own limitations. If I am not mistaken, in order to get both pan (1 touch) and zoom (2 touch), you have to combine it with Flickable?

            The QWidget API for gestures is so nice, it is a shame QQuickItem does not have an equivalent of that:

            this->grabGesture(Qt::PanGesture);
            this->grabGesture(Qt::PinchGesture);
            // ...
            
            p3c0P 1 Reply Last reply
            0
            • K kloffy

              @p3c0 Thank you! Yes, I did look at them, but it appears that PinchArea unfortunately has its own limitations. If I am not mistaken, in order to get both pan (1 touch) and zoom (2 touch), you have to combine it with Flickable?

              The QWidget API for gestures is so nice, it is a shame QQuickItem does not have an equivalent of that:

              this->grabGesture(Qt::PanGesture);
              this->grabGesture(Qt::PinchGesture);
              // ...
              
              p3c0P Offline
              p3c0P Offline
              p3c0
              Moderators
              wrote on last edited by
              #6

              @kloffy May be PinchArea is only for pinch gestures. I didn't find any such element which supports panning. Qt 4 had GestureArea which supported pan, zoom, swipe, tap etc.. but it seems they discontinued it.

              157

              K 1 Reply Last reply
              0
              • p3c0P p3c0

                @kloffy May be PinchArea is only for pinch gestures. I didn't find any such element which supports panning. Qt 4 had GestureArea which supported pan, zoom, swipe, tap etc.. but it seems they discontinued it.

                K Offline
                K Offline
                kloffy
                wrote on last edited by
                #7

                @p3c0 Yes, seems like it has been removed, which is a shame. I suppose I may have to install an event filter and roll my own solution. Looking at the amount of code that deals with gesture recognition in QWidget, this is a bit of a scary prospect, though. :(

                p3c0P 1 Reply Last reply
                0
                • K kloffy

                  @p3c0 Yes, seems like it has been removed, which is a shame. I suppose I may have to install an event filter and roll my own solution. Looking at the amount of code that deals with gesture recognition in QWidget, this is a bit of a scary prospect, though. :(

                  p3c0P Offline
                  p3c0P Offline
                  p3c0
                  Moderators
                  wrote on last edited by p3c0
                  #8

                  @kloffy You can try requesting such feature at http://bugreports.qt.io/. Or try asking here: http://lists.qt-project.org/mailman/listinfo/interest. May be there's some other alternative I'm too not aware of.

                  157

                  1 Reply Last reply
                  0
                  • M Offline
                    M Offline
                    M4271N
                    wrote on last edited by
                    #9

                    Are there any news about this? I would also be interested in using the gestures in the "traditional" way without using them in QML.

                    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