[solved]QML and Partial Image Displaying



  • Hi,

    is it possible to display q quarter of an image ? I mean, is it possible to specify how much of the image you want to display with proportion preservation. Displaying the end or the begginning. In QML or in QML with C++... Anything that can be plugged into QML.

    Thanks



  • An easy way to begin with is to place an "Image":doc.qt.nokia.com/4.7-snapshot/qml-image.html element in a "Rectangle":http://doc.qt.nokia.com/4.7-snapshot/qml-rectangle.html element. Let Rectangle be smaller than the Image and in the Rectangle set the clip:true. This show only a part of the Image.
    @
    Rectangle{
    clip:true
    width: 150
    height:150
    Image{
    source: "image/source.png"
    }
    }
    @

    To go a bit further replace the Rectangle with a "Flickable":http://doc.qt.nokia.com/4.7-snapshot/qml-flickable.html element. Thus if the image is smaller than the size of the Flickable you will be able to scroll the view of the image. So:

    @
    Flickable{
    clip:true
    width: 150
    height:150

    contentWidth: image.width
    contentHeight: image.height
    Image{
        id: image
        source: "image/source.png"
    }
    

    }
    @

    Does this do what you need?



  • Yes, it's exactly what i needed !

    Thanks !


Log in to reply
 

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