Results 1 to 5 of 5

Thread: Change the origin.x and origin.y to rotate a Path

  1. #1
    Join Date
    Sep 2015
    Posts
    32
    Qt products
    Qt5
    Platforms
    Windows
    Thanks
    5

    Default Change the origin.x and origin.y to rotate a Path

    Hi again,

    I guess the problem is fairly simple but even with my friends that know QT quick more than me we couldn't achieve a solution .



    Right now I have a simple animation that rotates my path 360 degrees.
    This code and the animation WORKS.
    I run the animation when SPACE is pressed.

    However I want to change the origin of the rotation transformation. By default it's x=0, y=0.



    What code should I use?
    And specifically where should I put it?



    My animation:
    Qt Code:
    1. SequentialAnimation {
    2. id: testAnimationDuPath2
    3. running: false
    4. loops: 1
    5. NumberAnimation { target: itemPrincipal; property: "rotation"; to: 360; duration: 1500 }
    6. }
    To copy to clipboard, switch view to plain text mode 




    The item containing Path, PathView and Delegate:
    Qt Code:
    1. Item {
    2. id: itemPrincipal
    3.  
    4. // initial state
    5. z:0
    6.  
    7.  
    8. ListModel {
    9. id: subTypeModel
    10. ListElement { name: "toto"; path: "file:///D:/test/toto"; }
    11. ListElement { name: "tata"; path: "file:///D:/test/tata"; }
    12. ListElement { name: "tutu"; path: "file:///D:/test/tutu"; }
    13. }
    14.  
    15. PathView {
    16. id: currentWheel
    17.  
    18. // Properties (THIS IS WHAT I TRIED, BUT THEN I PLACED THIS SAME CODE LIKE EVERYWHERE, WITHOUT ANY RESULT)
    19. transform:
    20. Rotation {
    21. id:rotationPath
    22. origin.x: 408;
    23. origin.y: 225;
    24. angle: 0;
    25. }
    26.  
    27. focus: true
    28.  
    29. model : gameListModel
    30.  
    31. FolderListModel {
    32. id: gameListModel
    33. }
    34.  
    35. path: Path {
    36. id:myPath
    37.  
    38. startX: 95; startY: 160
    39.  
    40. PathQuad { x: 43; y: 53 ; controlX: 18; controlY: 78}
    41. PathAttribute { name: "angle"; value: itemAngle }
    42.  
    43. PathQuad { x: 180; y: 22 ; controlX: 108; controlY: 26}
    44. PathAttribute { name: "angle"; value: itemAngle*2 }
    45.  
    46. PathQuad { x: 320; y: 19 ; controlX: 250; controlY: 21}
    47. PathAttribute { name: "angle"; value: itemAngle*3 }
    48.  
    49. PathQuad { x: 460; y: 22 ; controlX: 390; controlY: 21}
    50. PathAttribute { name: "angle"; value: itemAngle*4 }
    51.  
    52. PathQuad { x: 597; y: 53 ; controlX: 528; controlY: 37}
    53. PathAttribute { name: "angle"; value: itemAngle*5 }
    54.  
    55. PathQuad { x: 545; y: 159 ; controlX: 571; controlY: 106}
    56. PathAttribute { name: "angle"; value: itemAngle*6 }
    57. }
    58.  
    59.  
    60.  
    61. // Delegate Component:
    62. delegate: Image {
    63. id: wheelicon
    64.  
    65. z: PathView.z
    66.  
    67. }
    68.  
    69. }
    70.  
    71. }
    To copy to clipboard, switch view to plain text mode 



    Yours,
    --Jay

  2. #2
    Join Date
    Jan 2006
    Location
    Graz, Austria
    Posts
    8,416
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    Unix/X11 Windows
    Thanks
    37
    Thanked 1,544 Times in 1,494 Posts

    Default Re: Change the origin.x and origin.y to rotate a Path

    I am not sure what the problem is.

    You don't want to rotate the path view but the parent item?

    Cheers,
    _

  3. #3
    Join Date
    Sep 2015
    Posts
    32
    Qt products
    Qt5
    Platforms
    Windows
    Thanks
    5

    Default Re: Change the origin.x and origin.y to rotate a Path

    I guess you are right.
    I am still confused about all this.
    I spoke about rotation of the PATH because that is what VISUALLY happen on my screen, the path rotates, but with the wrong origin : )

    So first, for what I want to achieve, is this code right or do I need something else or in addition?

    Qt Code:
    1. transform:
    2. Rotation {
    3. id:rotationPath
    4. origin.x: 408;
    5. origin.y: 225;
    6. angle: 0;
    7. }
    To copy to clipboard, switch view to plain text mode 

    2) if the code is right, WHERE should I put it?
    I tried these places:
    a) as properties of the ITEM containing the listmodel, model, path, pathview, delegate
    b) in the path
    c) in the pathview
    d) in de delegate
    e) directly in the SequentialAnimation as PropertyChanges {}


    Arghh this is driving me crazy

    Yours,
    --Jay

  4. #4
    Join Date
    Jan 2006
    Location
    Graz, Austria
    Posts
    8,416
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    Unix/X11 Windows
    Thanks
    37
    Thanked 1,544 Times in 1,494 Posts

    Default Re: Change the origin.x and origin.y to rotate a Path

    Quote Originally Posted by JaySDC View Post
    Qt Code:
    1. transform:
    2. Rotation {
    3. id:rotationPath
    4. origin.x: 408;
    5. origin.y: 225;
    6. angle: 0;
    7. }
    To copy to clipboard, switch view to plain text mode 

    2) if the code is right, WHERE should I put it?
    If you want this to be the rotation of itemPrincipal, then put it into that item's transform property.

    You also need to change the target of you number animation to rotationPath, property angle.

    Cheers,
    _

  5. The following user says thank you to anda_skoa for this useful post:

    JaySDC (15th September 2015)

  6. #5
    Join Date
    Sep 2015
    Posts
    32
    Qt products
    Qt5
    Platforms
    Windows
    Thanks
    5

    Default Re: Change the origin.x and origin.y to rotate a Path

    Working Thx!

    I was referencing/calling anything BUT the id of the transform: rotation object.

    ++
    --Jay

Similar Threads

  1. Replies: 1
    Last Post: 14th September 2015, 11:33
  2. Painter rotation origin
    By alizadeh91 in forum Qt Programming
    Replies: 1
    Last Post: 10th March 2012, 14:14
  3. QwtsSlider Scale Origin
    By fruzzo in forum Qwt
    Replies: 3
    Last Post: 23rd November 2011, 12:23
  4. QwtThermo: origin of the fill
    By Marco Trapanese in forum Qwt
    Replies: 0
    Last Post: 31st May 2010, 15:50
  5. Rotating a rectangle about its origin
    By babu198649 in forum Newbie
    Replies: 5
    Last Post: 25th October 2008, 13:24

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.