PDA

View Full Version : Draw QtCanvasElipse on mouse press event position



YuriyRusinov
31st May 2006, 11:36
Hello, All !

I want to draw QtCanvasEllipse object on QtCanvas, I do


...
QtCanvasEllipse *ellipse = new QtCanvasEllipse ( 100, 100, view->canvas() );
ellipse->move ( event->pos().x(), event->pos().y() );
ellipse->setPen ( QPen( Qt::DashDotLine ) );
ellipse->setZ ( 10000 );
ellipse->show ( );
view->canvas()->setChanged ( view->viewport()->rect() );
view->canvas()->update();
...

but nothing drawing. I think that I move ellipse to position far from canvas. Which way I have to draw ellipse with mouse press event center ?

e8johan
31st May 2006, 11:57
Have a look at this: http://www.digitalfanatics.org/projects/qt_tutorial/chapter12.html - it shows howto use the canvas and how to respond to mouse events.