RubberBand in qml



  • I want to crop the Image in qml, like this

    "crop":http://www.flickr.com/photos/92283971@N04/9228168345/

    The region surrounded by the rectangle is the region I want to crop
    Do Qt provide any tools to make this job easier?

    @
    import QtQuick 2.1
    import QtQuick.Controls 1.0
    //import QtQuick.Layouts 1.0
    //import QtQuick.Dialogs 1.0

    Rectangle {
    id: root
    width: 1200
    height: 600

    Rectangle{
        anchors.fill: parent
    
        color: "black"
    
        Rectangle{
            id: rectDrag
    
            height: 100
            width: 100
    
            color: "transparent"
            border.width: 5
            border.color: "green"
            Drag.active: dragArea.drag.active
            radius: 10
    
            MouseArea {
                id: dragArea
                anchors.fill: parent
    
                drag.target: parent
            }            
        }
    }
    

    }
    @

    I can drag the rectangle and find out the coordinates of the rectangle
    But there are two questions I don't know how to solve

    1 : How could I adjust the size of rectDrag by pulling the corners of the rectDrag?
    2 : After I select the region, I need to translate the coordinates(region) to the coordinates
    of the original image, how could I translate the coordinates after scaling by the
    fillMode--Image.PreserveAspectFit?

    edit: found Qt offer a rubberband class in c++, maybe I could use it to implement the
    rubberband?


Log in to reply
 

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