0

I need a grid on a QGraphicsView, and i update my canvas every 35ms. How can i generate a grid with the best performance?

I'm using this now:

//vertical lines
    for(double i = 0; i < global::circuitWidth; i+= global::gridSize)
    {
        painter->drawLine(global::mmToPixel(i-global::circuitCornerX), -            global::mmToPixel(global::circuitCornerY),   global::mmToPixel(i-global::circuitCornerX), global::mmToPixel(global::circuitHeight-global::circuitCornerY));
    }
    //horizontal lines
    for(double i = 0; i < global::circuitHeight; i+= global::gridSize)
    {
        painter->drawLine(-global::mmToPixel(global::circuitCornerX), global::mmToPixel(i-global::circuitCornerY), global::mmToPixel(global::circuitWidth-global::circuitCornerX), global::mmToPixel(i-global::circuitCornerY));
    }

Now i realized that i can calculate a few parameters before, but any other than that? Maybe create an image an draw out that instead lines?

And also is there a way to boost QT's graphics performance with some settings?

1 Answers1

0

Assuming the grid doesn't change, build it up in with a QPainterPath and just draw that.

is there a way to boost QT's graphics performance with some settings?

Yes, there are several ways, though it depends on what you're doing. Using openGL is often much faster, though not always.

Community
  • 1
  • 1
TheDarkKnight
  • 27,181
  • 6
  • 55
  • 85