PDA

View Full Version : How do I paint directly ina QGraphcicsView?



extrakun
13th July 2009, 07:58
I am doing a drawing application, and the idea of adding a new line to a QGraphicsScene just to allow the users to draw a line from point A to point B looks unnecessarily contrived. Is it possible for me to overload QGraphicsView::paintEvent() and to get a QPainter there? I have tried, but it is not working.

Any advice would be welcomed.

wysota
13th July 2009, 08:48
Add the line normally :) Alternatively use Widget Overlay but it's probably better to add the line to the scene,

extrakun
13th July 2009, 09:03
I guess I am going with this solution for now. I mean, I could just draw the line in the view (just for the drag and dropping of line) and emit a signal one the mouseReleased event, which I think is a lot simpler than the example (Diagram Example) used in QT.

Thanks for your answer anyway :D

wysota
13th July 2009, 09:12
But why would you want to draw an extraordinary line in the view?