PDA

View Full Version : qt coordinate system



qtlearner123
17th April 2012, 13:08
Hi all,

i downloaded a code from Qtapplications.org website for a manometer. it is a very lengthy code so i am not posting the entire code. I do not have a very clear concept in coordinate system so some body please explain the following coordinates and how can i relate to the picture i am drawing (manometer). i am pasting parts of the code


painter.translate(width() / 2, height() / 2);
painter.scale(side / 335.0, side / 335.0);

static const int scaleTriangle[6] = { -6,141,6,141,0,129 };

painter.drawEllipse(-152,-152,304,304);


my main doubt is the first two lines what width and height actually mean and why it is getting divided by 2 and then 335 and 335.
Most of the code contains the dimensions like above and i don't understand those. please somebody explain me little bit and then direct me to the proper documentation.

thanks in advance,
regards,
satya

wysota
17th April 2012, 16:20
Width and height are the width and height of the widget. The first line moves the origin of the coordinate system of the painter to the centre of the widget. The second line scales the coordinate system so that it has a range of (-335, 335). In the end all operations are done using coordinates ranging from -335 to +335 with the (0,0) located in the middle of the widget.