Important: Please read the Qt Code of Conduct -

Draw grid in QGraphicsScene/QGraphicsView

  • Hi,
    I'm using Qt 5.2 with Qt creator. I' want to draw a lot of rectangle(100 to 1 million) and fill them with 2 colors. To do this quickly I choose to

    1- fill background with one color
    2-draw the complete grid with big lines
    3-and fill each rectangle with the second color.


    I've done this with direct2D and GDI, it worked well. But with Qt, I'm lost with QGraphiquesScene/view because all my rectangle need to be a square, but while extending my view I' get a weird result. With direct2D my grid size is the lowest size of my view.

    So I need your help. I'm using
    @painter->drawLines(, lines.size());@

    What I got with QT

    ! I got)!

  • @::drawBackground(QPainter *painter, const QRectF &rect)@

    I use rect to get the bound but it seem not work while expanding my view all going weird instead of grow up the size...

    I need a grid witch grow up with the view size .

  • No one knows how to draw a simple grid which grow up with view ?

Log in to reply