Results 1 to 3 of 3

Thread: Issiue with resizing a QGraphcisItem after rotation

  1. #1
    Join Date
    Jul 2015
    Posts
    2
    Qt products
    Qt5
    Platforms
    Unix/X11

    Default Issiue with resizing a QGraphcisItem after rotation

    Hello guys I am new to this forum and this is my first thread and now to my problem.

    I can not resize correctly after rotation. It seems like the position of my item is shifted.
    For example, if I place my item to the mouse position, the corner of my item is not under the mouse.
    It is shifted a little bit. It seems like something went wrong with my translation.
    I used the following code for rotation.

    Qt Code:
    1. QTransform transform;
    2. transform.translate(boundingRect().width()/2, boundingRect().height()/2);
    3. transform.rotate(getRotationAngle(event));
    4. transform.translate(-(boundingRect().width()/2), -(boundingRect().height()/2));
    5. setTransform(transform);
    To copy to clipboard, switch view to plain text mode 

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

    Default Re: Issiue with resizing a QGraphcisItem after rotation

    If you only rotate around the center, you could try setting the transform origin point to the center

    Cheers,
    _

  3. #3
    Join Date
    Jul 2015
    Posts
    2
    Qt products
    Qt5
    Platforms
    Unix/X11

    Default Re: Issiue with resizing a QGraphcisItem after rotation

    Do you mean like that:

    Qt Code:
    1. this->setTransformOriginPoint(boundingRect().width()/2 , boundingRect().height()/2);
    2. this->setRotation(getRotationAngle(event));
    3. this->setTransformOriginPoint(0 , 0);
    To copy to clipboard, switch view to plain text mode 

    Maybe I should explain how I resize. I resize my item through mouse move. User has to click on one of the four corners and then drag into a direction.

    I tried this too, but it only works for top left and bottom right corner.

Similar Threads

  1. Replies: 1
    Last Post: 12th December 2013, 16:08
  2. rotation and drawTexture
    By makism in forum Qt Programming
    Replies: 0
    Last Post: 24th May 2010, 08:01
  3. Replies: 3
    Last Post: 2nd March 2010, 20:58
  4. Rotation on Qframe
    By Pharell in forum Qt Programming
    Replies: 11
    Last Post: 2nd April 2008, 16:31
  5. Rotation problem
    By boss_bhat in forum Qt Programming
    Replies: 5
    Last Post: 17th January 2007, 16:46

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
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.