PDA

View Full Version : QTransform vs QMatrix



maverick_pol
3rd October 2007, 10:40
Hi guys,

I am currently studing QTransform and QMatrix classes, and see only one difference between those classes: QTransform allows perpective transformations. Could anyone explain this difference? Any example would be appreciated.

Thank you

Maverick

wysota
3rd October 2007, 11:56
I think you've explained it yourself. QTransform allows 3D transformations and is limited to QMatrix 2D transformations. So for example you can rotate something towards the screen (try it with an image).

Michiel
3rd October 2007, 12:01
Strange. Doesn't sound like a good reason to have two classes.

maverick_pol
3rd October 2007, 12:25
Strange. Doesn't sound like a good reason to have two classes.

Class designer should explain it : )

Thank you for help.

wysota
3rd October 2007, 12:41
The reason for having two classes is simple. QMatrix was introduced in Qt 3.0 as QWorldMatrix and is a direct port to Qt4 and QTransform was introduced in Qt 4.3 (I think) and simply extends QMatrix with new possibilities. AFAIK since 4.3 QMatrix is (or at least could be if not for complexity reasons) implemented using QTransform. As you can't remove a class from a newer version because of compatibility reasons, another class had to be added. That's a normal approach in Qt. For instance we have a few classes with "V2" (and even "V3") in their names that inherit their previous versions and extend them with new capabilities.

Michiel
3rd October 2007, 13:01
Yes, I thought that would be the reason. I don't like backward compatibility. ;-)

maverick_pol
4th October 2007, 09:42
Ok,

SO why not to extend the existing class, or add some other functionality, but to create a new class?

Ok..Just being curious.

Thanks

wysota
4th October 2007, 10:53
These are different matrices. For instance the detatchment (det()) returns different values for both matrices, therefore you can't just extend QMatrix to become QTransform. Already written code would stop working.