[Qt-interest] : Dynamic Painting linked with mouse movement

shivam priyadarshi shivam.priyadarshi at gmail.com
Fri Jun 5 23:53:09 CEST 2009


Hi Everybody

I am trying to paint dynamically on mouse movement. I have drawn a Qimage on
Viewport area of Q3ScrollView. Later in all the drawing i am opening
QPainter on this Qimage. Now when i draw line with mouse movement (without
clicking) it doesn't draw dynamically. The Seqence of operation is :

1> I Left click on image which determine the starting point of  line.  The
left click event has been handled and working fine
2> Release the Left click abd move the mouse, Line should be shown
dynamically drawing on Image :  This is not working, it does not show
dynamically the movement of line
3> Left click again at point where i need to stop. The Whole line get  drawn
between these two points.

Finally Line get drawn between these two points but it doesnot show dynamic
movement of line on QImage with movement of mouse.

I have already set this flag also   viewport()->setMouseTracking(true);

Following is the snippet of code.


void QucsView::paintEvent(QPaintEvent *event) // QucsView inherit
Q3ScrollView
{
  QPainter p (this);
  main_image  =  QImage(viewport()->size(),
QImage::Format_ARGB32_Premultiplied);
  p.drawImage(0,0,main_image);
}

void QucsView::MMovePainting(QMouseEvent *event)   // Handling Event Related
to movement of mouse.
{
QPainter Painter(&main_image); //open painter on Qimage
p->setPen(Qt::DotLine);
p->setCompositionMode(QPainter::RasterOp_NotSource);

---------- Some corordinate transformations --------
p->drawline(........);

}

The Same MMovePainting function of working fine with QT3(Dynamic movement
was visible) except there i didn't require QImage because in QT3.3 i can
paint outside paintEvent directly on ViewPort.

Is this related to QImage or some transparency property which got introduced
in QT4.

I will be grateful for your help.

regards:
Shivam
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.qt-project.org/pipermail/qt-interest-old/attachments/20090605/9add17af/attachment.html 


More information about the Qt-interest-old mailing list