How to use gestures in your Ubuntu phone to zoom in or out of a picture

Source: Internet
Author: User

For some applications, we want to use gestures to do some action. For example, use gestures to enlarge a picture, or rotate a picture. It's also a good way to enlarge your font for PDF readers. In this article, we'll show you how to use gestures.


In Qml, there is an element Pincharea. In this article there are also some introduction to "Qt Quick event Processing pinch zoom and rotation." This is no longer the case, we are directly affixed to our routine:


Import QtQuick 2.0import ubuntu.components 1.1/*! \brief MainView with a Label and Button Elements.*/mainview {//ObjectName for functional testing purposes (autopilot- QT5) ObjectName: "MainView"//note! ApplicationName needs to match the "name" field of the click Manifest ApplicationName: "Pinch.ubuntu"/* This PR Operty enables the application to change orientation when the device is rotated.    The default is False.    *///automaticorientation:true//Removes the old toolbar and enables new features of the new header. Usedeprecatedtoolbar:false Width:units.gu (Height:units.gu) Page {id:main title:i18n.tr (            "Simple") flickable {Id:flick anchors.fill:parent contentwidth:768                contentheight:1024 Pincharea {Width:Math.max (flick.contentwidth, Flick.width) Height:Math.max (flick.contentheight, flick.height) pinch. maximumscale:20;                pinch.minimumscale:0.2;                pinch.minimumrotation:0;                Pinch.maximumrotation:1;                    Property Real Initialwidth Real initialheight onpinchstarted: { Initialwidth = Flick.contentwidth initialheight = flick.contentheight} o Npinchupdated: {//adjust content pos due to drag flick.contentx + = PINCH.PREVIOUSC Enter.x-pinch.center.x Flick.contenty + = Pinch.previouscenter.y-pinch.center.y C                    Onsole.log ("Rotation:" + pinch.rotation);                    if (pinch.rotation > 0) flick.rotation + = 0.2;                    else flick.rotation-= 0.2; Resize Content flick.resizecontent (initialwidth * pinch.scale, Initialheight * Pinch.scale, Pinch.ce  Nter              } onpinchfinished: {//Move its content within bounds.                    Flick.returntobounds ()} Rectangle {Width:flick.contentWidth                        Height:flick.contentHeight color: "White" Image {                        Id:image anchors.fill:parent Source: "Images/sky.jpg"                Mousearea {Anchors.fill:parent}} }            }        }    }}


To run our application, you can see the following screen:



The source code for the entire project is: Git clone https://gitcafe.com/ubuntu/pinch.git



How to use gestures in your Ubuntu phone to zoom in or out of a picture

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.