Code:
{ point=e->pos(); setAttribute(Qt::WA_PaintOutsidePaintEvent, true); linepen.setCapStyle(Qt::RoundCap); linepen.setWidth(30); painter.setPen(linepen); painter.drawPoint(point); }
I used this code but it doesnt work
Printable View
Code:
{ point=e->pos(); setAttribute(Qt::WA_PaintOutsidePaintEvent, true); linepen.setCapStyle(Qt::RoundCap); linepen.setWidth(30); painter.setPen(linepen); painter.drawPoint(point); }
I used this code but it doesnt work
You normally should not need this, and you normally should not do this.
There is a way, but probably you don't need it.
Maybe if you explain why and what you are trying to do, we can show you how to do it the proper way.
Why don't you just put that drawing code in to the paintEvent()?
You can simply set a flag in the mousePressEvent() and evaluate that flag in your painEvent() and paint it only if the flag is set, for example.
i got the codeCode:
{ point=e->pos(); update(); } { setAttribute(Qt::WA_OpaquePaintEvent); linepen.setCapStyle(Qt::RoundCap); linepen.setWidth(30); painter.setPen(linepen); painter.drawPoint(point); }
it worked for me
You shouldn't use OpaquePaintEvent in this situation. And certainly you shouldn't set the flag in the paint event.