Results 1 to 6 of 6

Thread: Can I get current rotation of a QGraphicsView?

  1. #1
    Join Date
    Sep 2007
    Posts
    14
    Thanks
    4
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Can I get current rotation of a QGraphicsView?

    Hi All,

    I have a QGraphicsView that I am rotating various amounts based on a passed angle, about 10 times per second. Is there a way I can determine what the current rotational angle of the view is? For example, if I've rotated it 30, then -90, I'd like to know its current rotation is -60.

    I've tried to track this in my program, but after a while my tracked angle is quite different than the actual angle. I was tracking the previous angle (pa), subtracting it from the current angle (ca), and then rotating the view by (ca-pa) degrees...

    Is current rotation available or deriveable? THANKS!

    bjh

  2. #2
    Join Date
    Dec 2006
    Posts
    849
    Thanks
    6
    Thanked 163 Times in 151 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: Can I get current rotation of a QGraphicsView?

    Probably not: if you first translate, then rotate, what is your rotation?

    Therefore your best bet will be your initial idea. Try to find out why your code does not work.

    Paste your code here if you want us to take a look at it.

  3. #3
    Join Date
    May 2007
    Location
    Lublin, Poland
    Posts
    345
    Thanks
    40
    Thanked 8 Times in 4 Posts
    Qt products
    Qt3 Qt4
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: Can I get current rotation of a QGraphicsView?

    Hi,

    Are you talking about View or Scene transform ?
    You can always have a var to store current QTransform;

    Kacper
    Qt allows you to use everything you want
    wysota
    --------------------------------------------------------------------------------
    #if defined(Q_OS_UNIX) && defined(QT_DEBUG)
    abort(); // trap; generates core dump
    #else
    exit(1); // goodbye cruel world
    #endif

  4. #4
    Join Date
    Sep 2007
    Posts
    14
    Thanks
    4
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: Can I get current rotation of a QGraphicsView?

    Hi Again,

    Disclaimer: I inherited this code from the programmer before me, so I'm sure there are many things about it I don't yet know! We all know how that goes...

    maverick_pol - I'm not setting any transformation matrix. Just doing rotations with the painter, having done a centerOn() the center of my view. Can I set an identity matrix, and then call a method to see how it has changed? Thanks for answering!

    Caduel - I was afraid that was going to be the case. Guess I'd better dig into the code a little more to see where it is failing. I thought I might get lucky and have an easy way out! Thanks for answering!


    bjh

  5. #5
    Join Date
    Dec 2006
    Posts
    849
    Thanks
    6
    Thanked 163 Times in 151 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: Can I get current rotation of a QGraphicsView?

    from the Qt docs:
    Qt Code:
    1. QMatrix rotationMatrix(cosa, sina, -sina, cosa, 0, 0);
    To copy to clipboard, switch view to plain text mode 
    with sina being sin(a) and a being the rotation angle and so on.
    Assuming that only rotations took place... Using your math skills you can surely calculate a from cosa and sina.

    (I still think that keeping book of the rotation angle by pure addition of the deltas should be simpler und easier to understand than that. ;-)

    HTH

  6. The following user says thank you to caduel for this useful post:

    bjh (2nd October 2008)

  7. #6
    Join Date
    Sep 2007
    Posts
    14
    Thanks
    4
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: Can I get current rotation of a QGraphicsView?

    Hi Caduel,

    Math skills were not the issue. Turns out there was a logic flaw in tracking the previous rotations. Fixed that and all is working as expected!

    Appreciate your guidance!

    bjh

Similar Threads

  1. QGraphicsView Current Center
    By arjunasd in forum Qt Programming
    Replies: 4
    Last Post: 8th November 2010, 20:49
  2. Qt designer plugin errors on OSX Leopard
    By mpotocnik in forum Qt Tools
    Replies: 10
    Last Post: 21st January 2008, 09:45
  3. Distributing QT application for Mac OS
    By mb0 in forum Qt Programming
    Replies: 1
    Last Post: 31st May 2007, 18:59
  4. Extracting current rotation
    By Gopala Krishna in forum Qt Programming
    Replies: 5
    Last Post: 13th May 2007, 11:29
  5. Replies: 15
    Last Post: 21st April 2007, 17: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
  •  
Qt is a trademark of The Qt Company.