PDA

View Full Version : Flipping QWidget



prashant
10th November 2009, 08:25
I am sub classing QWidget and doing some custom painting in paint event. By default top left is considered as (0,0) and bottom right is (1,1). Is it possible to change the coordinate system so that bottom left will become (0,0) and top right (1,1)

I tried in paint event:


painter.scale(1,-1)

Doesn't work?

When clicking down on widget how do I retrieve the color at point? For example I am drawing a gradient in paint event and when I click down, (mouseDownEvent) I need to get the color of that pixel.

Similarly how do I retrieve the color at mouse down in QGraphicsView and QGraphicsScene.

high_flyer
10th November 2009, 09:41
Is it possible to change the coordinate system so that bottom left will become (0,0) and top right (1,1)
Yes, by using setWindow().
Read the docs about logical and physical coordinates:
http://doc.trolltech.com/4.4/coordsys.html#window-viewport-conversion