Nominate our 2022 Qt Champions!

QGraphicsView grid

  • Hello!

    I want to make a grid in my QGraphicView like in MS Visio, or AutoCAD software. Initially I have created class Point, subclass of QGraphicsItem, and added in the loop Points to QGraphicScene with addItem() function. So points form a grid. In this case everything looks ok, but performance issues appears. Application freeze, while adding thousand of items.

    My second idea was to use drawBackrground() function. And in this case it works fast, but artifacts appear. My algorithm of drawing Points is ok, the problem is that when I scroll View, background drawing can not get in time, and blank rows or columns appear.

    Any Ideas?

  • Well, if anyone interested, I ended up with drawBackground() function. And just added + extra 10% for area which in fact has to be redrawn. Now, there no "white spaces" appear while scrolling.

Log in to reply