Hello all,
I am working on a mathematics tutor app and so I need to transform my coordinate space into traditional Cartesian Coordinates.
I have found a solution here: http://stackoverflow.com/questions/4...painter-y-axis
which I have added to one of my QGraphicsItem object's paint() event handlers for testing but I would like to apply it at a more global scale. I looked at the widget I am using as the QGraphicsView as the place to set this however it doesn't have a paint(), just these:
virtual void drawBackground(QPainter * painter, const QRectF & rect)
virtual void drawForeground(QPainter * painter, const QRectF & rect)
To copy to clipboard, switch view to plain text mode
If I wanted to plug the code into my application so that EVERYTHING is drawn automagically in the coordinate system I need it to be, where is the best place to put it?
Code I have added to my QGraphicsItem:
// Setting the matrix rotates the drawing area to be a normal cartesian plane. Unfortunately
// it also means that the original drawing has to be tweaked
matrix.scale(1, -1);
pPainter -> setMatrix(matrix);
void PhysVector::paint(QPainter *pPainter, const QStyleOptionGraphicsItem *pOption, QWidget *) {
// Setting the matrix rotates the drawing area to be a normal cartesian plane. Unfortunately
// it also means that the original drawing has to be tweaked
QMatrix matrix;
matrix.scale(1, -1);
pPainter -> setMatrix(matrix);
To copy to clipboard, switch view to plain text mode
One further note I would like to make, is I would like to affect ONLY the drawing of objects, not the interaction of mouse clicks and what not. Unless they are inseparable I mean...
Thank you!
- Caolan
Bookmarks