Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. QML and Qt Quick
  4. [SOLVED]Qt Quick and QML Image Zoom
Forum Update on Monday, May 27th 2025

[SOLVED]Qt Quick and QML Image Zoom

Scheduled Pinned Locked Moved QML and Qt Quick
2 Posts 1 Posters 6.6k Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • W Offline
    W Offline
    Wroman
    wrote on 4 Jul 2013, 08:08 last edited by
    #1

    Hi there !

    I've got a problem on moving on my image when i zoom on it.

    Basically, i scale the image to reproduce a zoom.

    What i'm doing now is translating the image.

    @ property int transformX:0;
    property int transformY:0;

    Rectangle
    {
    id:borderEmulation;
    color: "lightgray";
    clip: true

            anchors
            {
                fill: parent;
                margins: 2;
            }
            Image
            {
                id: visibleImg;
                source: "qrc:/visible";
                antialiasing: true;
                fillMode: Image.PreserveAspectFit;
                //transformOrigin: Item.Center;
                transform: Translate { y: transformY*visibleImg.scale; x: transformX*visibleImg.scale }
                anchors
                {
                    fill:parent;
                    bottomMargin: myProgressBar.height+10;
                    margins: 2;
                }
            }
    

    }@

    And 4 button that increase / deacrease by 20 the transform(X/Y).

    My point is : is here a way to know when i'm zooming out of my picture ?

    ie. when i have to stop my translation because the right/left/top/bottom end of the image is displayed ?

    Regards

    Trust me, i'm an engineer !

    1 Reply Last reply
    0
    • W Offline
      W Offline
      Wroman
      wrote on 4 Jul 2013, 12:44 last edited by
      #2

      Solved by :

      @
      MouseArea
      {
      anchors.fill: parent;
      onClicked:
      {
      if(transformY > -((visibleImg.height/2 - (visibleImg.height-visibleImg.paintedHeight)/2)(visibleImg.scale-1)) + visibleImg.scale10)
      transformY -= visibleImg.scale10;
      else
      transformY = -(visibleImg.height/2 - (visibleImg.height-visibleImg.paintedHeight)/2)
      (visibleImg.scale-1);
      }
      }
      @

      Resp. with +/- and X/Y on the appropriate directions.

      Trust me, i'm an engineer !

      1 Reply Last reply
      0

      1/2

      4 Jul 2013, 08:08

      • Login

      • Login or register to search.
      1 out of 2
      • First post
        1/2
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • Users
      • Groups
      • Search
      • Get Qt Extensions
      • Unsolved