PDA

View Full Version : How to draw dynamic new information on painter. (moving elements )



tonnot
25th July 2011, 14:22
I remember the xor, or, etc Pen setting to draw lines into a 'picture' .
I used it to move one element without the need of redraw all the content of the vectorial data drawed.
To get this , what can I use from painter ? Maybe I have to see Graphicscene ?
Imagine the typical line-point movement. (when edit it wiht the mouse)-.
First you have to erase the lines from point 1 - EditPoint - Point2, then draw new point1-Editpoint , Editpoint- Point 2. And ths two things at every mouse move.

Any tips ? Thanks

Santosh Reddy
26th July 2011, 06:10
Not sure where you are drawing, if it is QGraphicsScene, as you already know use QGraphicsLineItem, and just use QGraphicsLineItem::setLine(x1,y1,x2,y2) on every mouse movement (drawing and erasing is taken care by QGraphicsScene)

SixDegrees
26th July 2011, 07:44
You can set logical drawing ops if you're drawing over a QImage; see QPainter::setCompositionMode. XOR mode is not longer available for ordinary drawing; the rationale is that modern graphics engines are so fast that there is no downside to simply caching the original background and drawing on top of it. This also makes color rendering more sane.

I'm not sure I agree with this, but it's the technique used in Qwt for rubberbanding.

tonnot
26th July 2011, 19:11
Thank you very much