May 3, 2012

Wroman Wroman
Lab Rat
18 posts

[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

 Signature 

Trust me, i’m an engineer !

2 replies

May 3, 2012

favoritas37 favoritas37
Lab Rat
148 posts

An easy way to begin with is to place an Image element in a Rectangle [doc.qt.nokia.com] element. Let Rectangle be smaller than the Image and in the Rectangle set the clip:true. This show only a part of the Image.

  1. Rectangle{
  2.     clip:true
  3.     width: 150
  4.     height:150
  5.     Image{
  6.         source: "image/source.png"
  7.     }
  8. }

To go a bit further replace the Rectangle with a Flickable [doc.qt.nokia.com] 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:

  1. Flickable{
  2.     clip:true
  3.     width: 150
  4.     height:150
  5.  
  6.     contentWidth: image.width
  7.     contentHeight: image.height
  8.     Image{
  9.         id: image
  10.         source: "image/source.png"
  11.     }
  12. }

Does this do what you need?

May 3, 2012

Wroman Wroman
Lab Rat
18 posts

Yes, it’s exactly what i needed !

Thanks !

 Signature 

Trust me, i’m an engineer !

 
  ‹‹ QML Extension Plugin failed to load      Did anyone use QtQuick with embedded linux on Freescale IMX53 ? ››

You must log in to post a reply. Not a member yet? Register here!