Hello,

I am implementing a painting program. For this I need to collect all coordinates along the mouse path and should color those pixels with specified color.
To collect coordinates I wrote code in mouseMoveEvent() as follows

Qt Code:
  1. void drawing::mouseMoveEvent(QMouseEvent *mouseEvent)
  2. {
  3. cp=mouseEvent->pos();
  4.  
  5.  
  6. if(cur.x()==-1)
  7. cur=cp;
  8.  
  9. LineDrawing(cur.x(),cur.y(),cp.x(),cp.y(),20); //Collects pixels of 20 Cursor size
  10. cur=cp;
  11. }
To copy to clipboard, switch view to plain text mode 

The "LineDrawing" will collect all coordinates (cursor size of 20 in rectangle shape) from cur point to cp point.

This is working only if I mouse mouse slowly and the drawing is smooth. If I mouse mouse fast then the drawing is not smooth. That is the drawing of the color is not coming with the mouse. This is because of "Linedrawing" function code. The length between cur point and cp is more (say 20 pix length) so LineDrawing is not returning quickly.

This drawing I did in VC++. There in "MouseDownEvent" I wrote the code like this

void drawing::onLbuttonDown(..)
{

cp=mouseEvent->pos();


if(cur.x()==-1)
cur=cp;

while(true)
{
GetCursorPos(&cp) //Get's the current cursor pooint
LineDrawing(cur.x(),cur.y(),cp.x(),cp.y(),20); //Collects pixels of 20 Cursor size
cur=cp;

GetMessage(&msg,NULL,0,0);
if (msg.message==WM_LBUTTONUP)
break;


}

This is giving smooth drawing because the length between cur and cp is very small (say 3 pix length) and LineDrawing returns quickly.

In Qt is there any function to get message from message queue directly (like GetMessage() in VC++). So I can do my code in Qt also.

If this approach is wrong can you please guide me how to implement paint (collect pixels along mouse path of cursor size).

Thanks in advance
anki.n

}