PDA

View Full Version : How to get mouse's position?



coralbird
20th July 2006, 08:47
I want to get mouse's position in a widget not through QMouseEvent,How can I do this?
thanks!

high_flyer
20th July 2006, 10:52
then you will have to work directly with X.
(Why can't you use QMouseEvent?)

jpn
20th July 2006, 11:17
QPoint p = widget->mapFromGlobal(QCursor::pos());

coralbird
23rd July 2006, 04:52
then you will have to work directly with X.
(Why can't you use QMouseEvent?)

sure,I am building a GUI program, but mouseMove event just can be captured when left
or right button is pressed, which is different with windows ,and grap mouse input is
dangerous,so I have to get mouse position in timerEvent().

coralbird
23rd July 2006, 04:52
QPoint p = widget->mapFromGlobal(QCursor::pos());


Thanks a lot! I will test it.