Results 1 to 6 of 6

Thread: QWMatrix::mapRect

  1. #1
    Join Date
    Sep 2007
    Posts
    22
    Thanks
    1

    Default QWMatrix::mapRect

    Hello all,

    I am fighting with a problem regarding mapping a rectangle which is not of

    QRect type. I want to rotate the rectangle 90 degree counterclockwise and

    I just did it as follow but the result is not what I want.Instead the rectangle

    gets larger in size. Can someone give me suggestions how to solve this problem?

    Qt Code:
    1. QWMatrix matrixWorld;
    2. QRect newRect;
    3. double rotateDegree = 90.0;
    4.  
    5. newRect.setRect(myRect.Left(), myRect.Top(), myRect.Width(), myRect.Height());
    6. matrixWorld.rotate(rotateDegree);
    7. newRect = matrixWorld.mapRect(newRect);
    8. myRect.Rect(newRect.left(), newRect.top(), newRect.width(), newRect.height());
    To copy to clipboard, switch view to plain text mode 
    Last edited by Pharell; 28th August 2008 at 14:38.

  2. #2
    Join Date
    Oct 2006
    Location
    New Delhi, India
    Posts
    2,467
    Thanks
    8
    Thanked 334 Times in 317 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: QWMatrix::mapRect

    What is QWMatrix ???

  3. #3
    Join Date
    Sep 2007
    Posts
    22
    Thanks
    1

    Default Re: QWMatrix::mapRect

    The QWMatrix class specifies 2D transformations of a coordinate system.
    The standard coordinate system of a paint device has the origin located at the top-left position. X values increase to the right; Y values increase downward.

  4. #4
    Join Date
    Sep 2007
    Posts
    22
    Thanks
    1

    Default Re: QWMatrix::mapRect

    Anyone knows how to solve this problem??

  5. #5
    Join Date
    Aug 2008
    Location
    Ukraine, Krivoy Rog
    Posts
    1,963
    Thanked 370 Times in 336 Posts
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: QWMatrix::mapRect

    in Qt I found only QMatrix and there are some small examples with rotation. the interafe of this class very similar to class which you was describe.

  6. #6
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    5,372
    Thanks
    28
    Thanked 976 Times in 912 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: QWMatrix::mapRect

    You can do the 90 degrees rotation without any matrices. Just swap coordinates and multiply one of them by -1.

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.