PDA

View Full Version : QWMatrix::mapRect



Pharell
28th August 2008, 14:33
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?


QWMatrix matrixWorld;
QRect newRect;
double rotateDegree = 90.0;

newRect.setRect(myRect.Left(), myRect.Top(), myRect.Width(), myRect.Height());
matrixWorld.rotate(rotateDegree);
newRect = matrixWorld.mapRect(newRect);
myRect.Rect(newRect.left(), newRect.top(), newRect.width(), newRect.height());

aamer4yu
28th August 2008, 19:27
What is QWMatrix ???

Pharell
29th August 2008, 09:08
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.

Pharell
29th August 2008, 14:47
Anyone knows how to solve this problem?? :confused:

spirit
29th August 2008, 16:08
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.

jacek
29th August 2008, 16:32
You can do the 90 degrees rotation without any matrices. Just swap coordinates and multiply one of them by -1.