Qt - Problem when drawing Cartesian coordinate system with QGraphicsItem

0

I have the following problem. I'm trying to graph the X and Y coordinate system. I use a QGraphicsItem. This graphicsitem has the upper coordinate X and Y ... as I move to the right, the X grows and to the left the X decreases, as is normal in the coordinate system. Now ... my problem is the Y axis ... as I go down it GROWS and should DECRECE and when I go up it DECRECES when in the coordinate system it should GROW. It is understood? ... I leave the definition of the code that I have ... it is a portion ... I hope you understand the problem.

QPointF centralPoint = QPointF(0, 0);
farmGraph = new FarmGraph(_size, centralPoint);

And the FarmGraph class, in its boundingRect, which is the important thing in the definition, is the following:

QRectF FarmGraph::boundingRect() const
{
    return QRectF(_centralPoint.x() - (_size/2),
              _centralPoint.y() - (_size/2),
              _size,
              _size);
}

I mean ... it's like I have to "mirror" on the Y coordinate so I can plot curves accordingly.

    
asked by Emiliano Torres 05.05.2018 в 04:55
source

1 answer

0

I already found him back googling a bit and with an example that I found. I publish the solution in case someone serves and I close the question. The solution is to invert, by means of the negative scale, the Y axis as follows:

QPointF centralPoint = QPointF(0, 0);
farmGraph = new FarmGraph(_size, centralPoint);
farmGraphi->setTransform(QTransform().scale(1, -1));
    
answered by 05.05.2018 / 05:35
source