PDA

View Full Version : drawing a grid



dreamer
26th April 2008, 19:56
how can i draw a grid of points on a widget of type QgraphicsView?

I reimplement the PaintEvent method in my custom QgraphicsView class, but i can't see the points i draw......

A simple line drawing i have implemented:


void myview::paintEvent(QPaintEvent* event){
qreal x,y,w,h;
myscene->sceneRect().getRect(&x,&y,&w,&h);

QPainter painter(this);
painter.setPen(Qt::black);
painter.drawLine(x,y,w/2,h/2);

QGraphicsView::paintEvent(event);
}

aamer4yu
26th April 2008, 21:11
re implement the drawBackground() method of scene class.

also in ur code above, u were just drawing a line. not points i guess. check ur code again what it does

dreamer
27th April 2008, 10:17
It was just an example.......
however, i resolve the problem reimplementing drawbackground() and drawforeground() in my custom QGraphicsScene class...

thx