PDA

View Full Version : QGraphicsScene illustrating the position of a joystick



Texton
21st August 2012, 20:29
Hi all.

I am getting inputs from a joystick through the serial port, and I want to make a visual representation of the X and Y coordinates from the joystick.

Therefore I need some kind of coordinate system with a point (small dot) showing the position of the joystick. I have read a lot about viewports, graphicscenes, and Pixmaps and now I (finally) have a .png file (my dot) shown in the scene.

Problem now is that the viewport always "centers" the scene somehow, so whenever I change the position of the dot in the scene the viewport automatically changes the position of the scene (if I understand this correctly). The result is that the dot isn't changing position "visually".

So I need a way to fixe the scene or something?.. Help please :)

Texton
21st August 2012, 22:40
Oh I found a way:

scene->setSceneRect(0, 0, ui->graphicsView->width(), ui->graphicsView->height());