PDA

View Full Version : Problem in MouseMove Event



Gamalof
17th June 2008, 20:10
i want to Get the position( x,y) of the cursor moving on my custom QGraphicsView Control

So, i made new class "MyQGraphicsView : QGraphicsView"

then i defined and implemented "mouseMoveEvent"

in MyQGraphicsView .h



void mouseMoveEvent ( QMouseEvent * event);


in MyQGraphicsView.cpp



void MyGraphicsViwer::mouseMoveEvent ( QMouseEvent * event )
{
MainForm->ui.Txt_xValue->setText((QString::number)(x()));
}


the problem is in the first mouse move, the Txt_xValue displays value 100, then it doesn't change where ever the mouse moves.

So ?

Thanks :)

jpn
17th June 2008, 20:34
viewport()->setMouseTracking(true);

Gamalof
17th June 2008, 21:14
Thanks for your reply, but .. it still not working.
still displaying the same result "100"

AD
17th June 2008, 21:18
event -> x()? Do it works?

Gamalof
17th June 2008, 21:24
Thanks A lot jpn, Worked :)