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. Image - apply rotation on condition

Image - apply rotation on condition

Scheduled Pinned Locked Moved Solved QML and Qt Quick
4 Posts 2 Posters 946 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.
  • V Offline
    V Offline
    Vinayak17
    wrote on last edited by
    #1

    Hello guys, please help me!

    I am using Image item type to display one image along with setting the rotation property as below:

    Image
    {
    transform: Rotation {
    origin.x: 0
    origin.y: height / 8
    axis {
    x: 0
    y: 1
    z: 0
    }
    angle: 60
    }
    source: "qrc:/image/abc.png"
    }

    Now I want the rotation to apply only when I am displaying abc.png image whereas I don't want to apply the rotation if I am using xyz.png. How can I achieve this task?

    1 Reply Last reply
    1
    • ODБOïO Offline
      ODБOïO Offline
      ODБOï
      wrote on last edited by ODБOï
      #2

      Hello @Vinayak17 !

      you can use JS expression like this :

      angle : source == "qrc:/image/abc.png" ? 60 : 0

      Or you can create a function that will return a rotation based on the image name

      function rotationByName(imgSource){
      var rot = 0;
      switch(imgSource){
      case "qrc:/image/abc.png" : rot = 60;break;
      case "qrc:/image/hij.png" : rot = 33;break;
      default : break;
      }
      return rot
      }

      and then use this function :

      rotation : rotationByName(myImg.source)

      I hope this will help you.
      LA

      1 Reply Last reply
      2
      • V Offline
        V Offline
        Vinayak17
        wrote on last edited by
        #3

        Yes, that works! Thanks a lot :)

        ODБOïO 1 Reply Last reply
        1
        • V Vinayak17

          Yes, that works! Thanks a lot :)

          ODБOïO Offline
          ODБOïO Offline
          ODБOï
          wrote on last edited by
          #4

          @Vinayak17 Perfect ;) you can upVote if you want !
          LA

          1 Reply Last reply
          0

          • Login

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