PDA

View Full Version : how to simulate mouse click behavior?



hashb
31st August 2010, 08:02
Hi All,

5123

what I am suppose to do is to simulate the mouse click event,

for example:
if user click the button in the above picture, it may send out a mouse click event :
QMouseEvent(
(QEvent::MouseButtonPress),
QPoint(10,10),
Qt::LeftButton,
Qt::LeftButton,
Qt::NoModifier
)
just as if the user click QPoint(10,10) of the window.
so the QGraphicsTextItem "aaa" will be selected.


but one problem is that I cann't use the postevent method,
because I don't know the receiver , I just want to simulate the true behavior of a mouse,
when click the button,it can simulate click anywhere inside the window.

is it possible ?

Thanks advance for your help.
Best regards,
hb

nish
31st August 2010, 08:16
if you dont have the reciever pointer then how would you know where the QPoint of the click should be? change your code to somehow have the pointer to the widget available.

hashb
31st August 2010, 08:53
Hi MrDeath,

When user click mouse on the window, she/he don't know the receiver ,right?
in fact, I have a widget which covered the whole Qgraphicview, when user click the widget I can get the position of the mouse.
then I want to simulate the mouse click to the QGraphicView inside the window, just as if the user click the QGraphicView directly.

Best regards,
hb