Results 1 to 5 of 5

Thread: Rotating a line without moving it in QML

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #4
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,372
    Thanks
    3
    Thanked 5,019 Times in 4,795 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: Rotating a line without moving it in QML

    "x" and "y" are defined relatively to the parent. Thus you cannot reference other item's "x" and "y" values as they are in a different coordinate system. This is similar to:

    javascript Code:
    1. Item {
    2. id: i1
    3. x: 10
    4. Item {
    5. id: i2
    6. x: 10
    7. }
    8. }
    To copy to clipboard, switch view to plain text mode 

    Item "i2" has an absolute x value set to 20 as it is translated by 10 relative to its parent. If instead you do:
    javascript Code:
    1. Item {
    2. id: i1
    3. x: 10
    4. Item {
    5. id: i2
    6. x: parent.x+10
    7. }
    8. }
    To copy to clipboard, switch view to plain text mode 

    Then i2.x == 20 and thus the absolute value is 30 and not 20.

    In your code the transformation origin should be set to:

    javascript Code:
    1. origin.x: line.width/2;
    2. origin.y: line.height/2;
    To copy to clipboard, switch view to plain text mode 

    which is equivalent to setting transformOrigin to Item.Center (which is the default).
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  2. The following user says thank you to wysota for this useful post:

    TheIndependentAquarius (5th June 2014)

Similar Threads

  1. rotating a qwtplot
    By pellegrini in forum Qwt
    Replies: 2
    Last Post: 20th March 2014, 09:11
  2. Rotating Items
    By PauloF91 in forum Newbie
    Replies: 7
    Last Post: 27th May 2013, 23:46
  3. Rotating Gradient
    By JeffC in forum Newbie
    Replies: 3
    Last Post: 3rd June 2012, 11:11
  4. Rotating pixmap
    By jano_alex_es in forum Newbie
    Replies: 4
    Last Post: 19th December 2010, 04:00
  5. Replies: 0
    Last Post: 24th May 2010, 12:19

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Qt is a trademark of The Qt Company.