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. Transform origin of an Item
Forum Updated to NodeBB v4.3 + New Features

Transform origin of an Item

Scheduled Pinned Locked Moved Solved QML and Qt Quick
3 Posts 3 Posters 517 Views 1 Watching
  • 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.
  • L Offline
    L Offline
    Luckless
    wrote on last edited by
    #1

    I have a Rectangle where I want to plot some images and I need the origin to be at the center of this rectangle. So that when I place my image at (0,0), It gets automatically placed at the center of my rectangle . I have implemented this by adding an offset to the x and y attribute of my image.

    Is there a better way of doing this, where I don't have to add an offset every time I want to add an image ?

    jsulmJ 1 Reply Last reply
    0
    • IntruderExcluderI Offline
      IntruderExcluderI Offline
      IntruderExcluder
      wrote on last edited by
      #3

      Sure, use Translate:

      Image {
          ...
          transform: Translate { ... }
      }
      
      1 Reply Last reply
      2
      • L Luckless

        I have a Rectangle where I want to plot some images and I need the origin to be at the center of this rectangle. So that when I place my image at (0,0), It gets automatically placed at the center of my rectangle . I have implemented this by adding an offset to the x and y attribute of my image.

        Is there a better way of doing this, where I don't have to add an offset every time I want to add an image ?

        jsulmJ Offline
        jsulmJ Offline
        jsulm
        Lifetime Qt Champion
        wrote on last edited by jsulm
        #2

        @Luckless said in Transform origin of an Item:

        Is there a better way of doing this, where I don't have to add an offset every time I want to add an image ?

        I don't think so, the origin (0,0) is left upper corner in Qt. You have to translate it to what ever other origin you want to have.

        For QML see what @IntruderExcluder suggested.

        https://forum.qt.io/topic/113070/qt-code-of-conduct

        1 Reply Last reply
        0
        • IntruderExcluderI Offline
          IntruderExcluderI Offline
          IntruderExcluder
          wrote on last edited by
          #3

          Sure, use Translate:

          Image {
              ...
              transform: Translate { ... }
          }
          
          1 Reply Last reply
          2

          • Login

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