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
hi,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"
-
signals: void clicked(); private: QPoint clickOrigin; protected: void mousePressEvent(QMouseEvent *ev){ clickOrigin = ev->pos(); ev->ignore(); } void mouseReleaseEvent(QMouseEvent *ev){ if( (abs(ev->x()- clickOrigin.x())< this->width()/10 ) && (abs(ev->y() -clickOrigin.y()) < this->height()/10) ) emit clicked(); ev->ignore(); }
-
@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" }
Best,
GT -
@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.