zoukankan      html  css  js  c++  java
  • 怎样在QML中使用multitouch

    在Qt QML中。它能够利用multitouch来做一些我们想做的事情。在今天的文章中。我们将介绍怎样使用multitouch来做一些我们想做的事。


    事实上,在QML中利用多点触控是很easy的一件事。我们以下直接来展示我们的例程来给大家解说一下:


    import QtQuick 2.0
    import Ubuntu.Components 1.1
    
    /*!
        rief 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: "multitouchtest.liu-xiao-guo"
    
        /*
         This property 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
    
         units.gu(60)
        height: units.gu(85)
    
        Page {
            title: i18n.tr("multitouchtest")
    
            MultiPointTouchArea {
                anchors.fill: parent
                touchPoints: [
                    TouchPoint { id: point1 },
                    TouchPoint { id: point2 },
                    TouchPoint { id: point3 },
                    TouchPoint { id: point4 }
                ]
            }
    
            Image {
                 parent.width/5
                height: parent.height/5
                source: "images/image1.jpg"
                x: point1.x
                y: point1.y
            }
    
            Image {
                 parent.width/5
                height: parent.height/5
                source: "images/image2.jpg"
                x: point2.x
                y: point2.y
            }
    
            Image {
                 parent.width/5
                height: parent.height/5
                source: "images/image3.jpg"
                x: point3.x
                y: point3.y
            }
    
            Image {
                 parent.width/5
                height: parent.height/5
                source: "images/image4.jpg"
                x: point4.x
                y: point4.y
            }
    
        }
    }
    


    如上面的介绍的那样,我们定义了一个“MultiPointTouchArea”。我们在Image中,绑定它们的坐标和TouchPoint在一起。这样。TouchPoint的坐标变化时,Image能够随时移动。 在它的里面。我们同一时候定义了4个TouchPoint。当我们仅仅有一个手指触屏时,我们能够看见仅仅有image1.jpg能够随着我们的手指移动:


      


    当我们同一时候两个手指触屏时。我们能够看到同一时候能够有两个图片image1.jpg及image2.jpg来同一时候移动我们的画面:



    同一时候3个手指触屏时,我们能够看到3个照片同一时候出如今屏幕上。并随我们的手指移动:




    整个项目的源代码在:https://github.com/liu-xiao-guo/multitouchtest


  • 相关阅读:
    Lucene基础排序算法改进
    大数据量的过滤 (用于爬虫,蜘蛛) Bloom Filter 布隆过滤器
    往空间,博客里添加音乐播放器
    汇编随笔
    一个女程序员的故事(酷壳陈皓)
    cmd 命令之删除整个文件夹
    亿度空间
    用wubi.exe安装ubuntu下载速度很慢怎么办?
    qtm第一次
    copy的妙用
  • 原文地址:https://www.cnblogs.com/mthoutai/p/6924040.html
Copyright © 2011-2022 走看看