Can not click button when Pinch, Zoom and then drag position

  • Hi

    Currently, I have an issue with my app which when Pinch, Zoom and then drag position then i can not click on any button of App

    I searched google but not see someone like me.

    pls help me about this

    Thanks and best regards

  • @thuongnv284

    I don't know how you implemented your Pinch Zoom and Drag functions, but I asume you did it at leas partially by overwriting MouseEvents.

    The solution is simply enough. Only accept Pinch, Zoom and Drag, when a certain minmal distance from the mousepressevent has been exceeded.

    Everything in that margin, you can handle as "clicks"

  • @J.Hilk thanks for your help

    Could you provide some code for this content or example for more detail.

    thanks you so much

  • @thuongnv284

        void clicked();
    QPoint clickOrigin;
    void mousePressEvent(QMouseEvent *ev){
        clickOrigin = ev->pos();
    void mouseReleaseEvent(QMouseEvent *ev){
        if( (abs(ev->x()- clickOrigin.x())< this->width()/10 )  && (abs(ev->y() -clickOrigin.y()) < this->height()/10) )
        emit clicked();

  • @J.Hilk Thanks u for help

    I mean i want to process this by QML design

  • @thuongnv284 Well, you haven't mentioned QML at all so far. I'm afraid I can't help you then, I don't have experience with QML.

  • Hi

    I found the root of this issue. When i use onClicked property in MouseArea, i see that i can click button on Android instead before i used onPressed.

  • Hi everyone

    But, i encountered a problem as follow:
    when i using onClicked i change image of button from image 1 to image 2 and then i want after clicked will change image 2 to image 1. it is same onPressed and onRelease.
    Do you have any solve for me? thanks you so much

  • Hi,
    it is hard to guess what behavior you exactly expect without some more code or information,
    but why don't you just use a property binding to link the pressed state of the MouseArea to the source for your image?

    MouseArea {
      id: mouseArea
    Image {
      source: mouseArea.pressed ? "/path/to/image1" : "/path/to/image2"


  • @GTDev Thanks for your help

    When you show for me i see that it is really simple. Thanks you so much :)

  • @GTDev Hi,

    Do you know why on Android device if i use onClicked then i can touch but if i use onPressed then i can not? I do not understand the reason of this. Pls help me

  • @thuongnv284
    usually the Clicked action is handled after the mouse/finger is released, where as onPressed obvioulsy emits/handles the action when the mouse/finger is first pressed.

    Gesturehandling lies exactly in between those 2. When the mouse/finger is pressed/on the screen and is moved around.

Log in to reply

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.