Perspective transformations on a QGraphicsView

Published Thursday March 1st, 2007
7 Comments on Perspective transformations on a QGraphicsView
Posted in Graphics Items, Graphics View, Labs, Qt

I don’t have much to say this time, just wanted to share a screenshot after I changed the 40000 Chips demo a bit. I replaced the single horizontal rotation-slider with three ones, each controlling one axis or rotation for the view. QTransform is really easy to use, and with some twiddling (thumb up, pointing finger straight and your index finger pointing to the left), you can get some pretty amazing effects.


QGraphicsView view(&scene);

QTransform transform;
transform.rotate(45, Qt::XAxis);
transform.rotate(22.5, Qt::YAxis);

view.setTransform(transform);
view.show();

Setting one on a QGraphicsView works well, but there are still some rough edges that’ll get fixed pretty soon. Anyway, this is what it looks like (interaction works just as well).


Transform - small

Do you like this? Share it
Share on LinkedInGoogle+Share on FacebookTweet about this on Twitter

Posted in Graphics Items, Graphics View, Labs, Qt

7 comments

wysota says:

Does it use OpenGL hardware acceleration for QGLWidget viewport?

Andreas says:

Hi, Wysota. QGLWidget uses hardware acceleration if your drivers support it, this screenshot shows that OpenGL is enabled on all views, so it uses QGLWidget for all viewports. But as you can see from the top-left view, my driver doesn’t support samplebuffers, so antialiasing has no effect.

wysota says:

No, no – I know QGLWidget uses hardware acceleration. I meant to ask if it uses OpenGL for QTransform effects.

Andreas says:

QGLWidget uses OpenGL for everything.

Zandru says:

looks awesome πŸ™‚ i have an offtopic hint for you: if you use Alt-PrintScreen for your Screenshots, you don’t have to manually clip them πŸ˜‰

Chris says:

My problem with the current QMatrix/QGraphicsView is that I can’t scroll maps forever. Imagine a map of the earth and I scroll right, then I want to start seeing the portion of the map formally on the left.

For example,
http://mathworld.wolfram.com/CylindricalEquidistantProjection.html

If I scroll right on the map in the above link, I want to see Australia show up on the left. Is this possible with QTransform?

Andreas says:

Nope, QGraphicsView can’t do spherical projection. It just (4.3) got support for perspective transformations… I guess the more features we add, the more possibilities you see ;-).

Commenting closed.

Get started today with Qt Download now