Results 1 to 5 of 5

Thread: QGraphicsView + rotate around axis ?

  1. #1
    Join Date
    Dec 2009
    Posts
    50
    Thanks
    9
    Qt products
    Qt4
    Platforms
    Windows

    Default QGraphicsView + rotate around axis ?

    Hi All

    I'm trying to rotate my scene with several Items. I'm looking at the scene and I want rotate the scene around some point( point equal to centerTo idealy ).

    Qt Code:
    1. void MyGraphicsView::updateTransform()
    2. {
    3. QTransform tr;
    4. tr.rotate(m_yRotate/1.0, Qt::YAxis);
    5. tr.rotate(m_xRotate/1.0, Qt::XAxis);
    6. tr.translate(some_point.x(), some_point.y());
    7. setTransform(tr);
    8. /**/
    9. }
    To copy to clipboard, switch view to plain text mode 

    In other words how can I change the position of YAxis or/and XAxis during such transform?
    So far rotation is done around some Axis I can not controll.

    I've tryed to play with:

    translate
    setTransformationAnchor(QGraphicsView::NoAnchor);
    setResizeAnchor(QGraphicsView::NoAnchor);
    setAlignment();


    Any ideas ?

    Thank you!

  2. #2
    Join Date
    Jan 2006
    Location
    Belgium
    Posts
    1,938
    Thanked 268 Times in 268 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows
    Wiki edits
    20

    Default Re: QGraphicsView + rotate around axis ?

    You translate the coordinate system before you rotate around the new coordinate system

  3. #3
    Join Date
    Dec 2009
    Posts
    50
    Thanks
    9
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: QGraphicsView + rotate around axis ?

    I belive I do that.
    In the code above I do tr.translate(some_point.x(), some_point.y());

    Some point - is point I want rotation around. But it seems like it does not work.

  4. #4
    Join Date
    Jan 2006
    Location
    Belgium
    Posts
    1,938
    Thanked 268 Times in 268 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows
    Wiki edits
    20

    Default Re: QGraphicsView + rotate around axis ?

    No, you rotate first and then do a translation.
    Try putting the translate before the two rotates and see what happens.

    Or to be more clear: the transformations are performed in the order you write them.

  5. #5
    Join Date
    Dec 2009
    Posts
    50
    Thanks
    9
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: QGraphicsView + rotate around axis ?

    Thank you! I've tryed that.
    Does not make any difference
    The scene is still rotates around some "other" axis.
    What elese could I do ?

Similar Threads

  1. Rotate QGraphicsProxyWidget in QGraphicsView
    By volcano in forum Qt Programming
    Replies: 14
    Last Post: 13th January 2010, 13:58
  2. rotate in QState
    By estel in forum Qt Programming
    Replies: 0
    Last Post: 21st October 2009, 12:39
  3. Rotate QLabel
    By Qt Coder in forum Newbie
    Replies: 2
    Last Post: 19th March 2009, 11:25
  4. how to rotate an image...
    By sh123 in forum Qt Programming
    Replies: 2
    Last Post: 15th January 2009, 14:59
  5. QGraphicsRectItem::rotate()
    By LestorN in forum Qt Programming
    Replies: 1
    Last Post: 20th October 2006, 10:17

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.