Results 1 to 3 of 3

Thread: how to simulate mouse click behavior?

  1. #1
    Join Date
    Jun 2009
    Posts
    74
    Thanks
    23
    Thanked 2 Times in 2 Posts

    Question how to simulate mouse click behavior?

    Hi All,

    snap1.png

    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

  2. #2
    Join Date
    Jun 2007
    Location
    India
    Posts
    1,042
    Thanks
    8
    Thanked 133 Times in 128 Posts
    Qt products
    Qt3 Qt4 Qt/Embedded
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: how to simulate mouse click behavior?

    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.

  3. #3
    Join Date
    Jun 2009
    Posts
    74
    Thanks
    23
    Thanked 2 Times in 2 Posts

    Default Re: how to simulate mouse click behavior?

    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

Similar Threads

  1. How to simulate QTouchEvent using mouse
    By dpatel in forum Qt Programming
    Replies: 5
    Last Post: 28th April 2016, 01:40
  2. Incorrect mouse behavior in GraphicsScene
    By framalex in forum Newbie
    Replies: 9
    Last Post: 11th June 2010, 23:43
  3. Replies: 4
    Last Post: 15th March 2010, 14:49
  4. Simulate QMenu behavior
    By Remenic in forum Qt Programming
    Replies: 2
    Last Post: 24th September 2009, 19:48
  5. Changing mouse grabbing behavior?
    By FlyingSaucrDude in forum Qt Programming
    Replies: 0
    Last Post: 11th November 2008, 01:04

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.