Results 1 to 5 of 5

Thread: how to send a emulated mouse event to QListWidget

  1. #1
    Join Date
    May 2008
    Posts
    58
    Thanks
    2

    Question how to send a emulated mouse event to QListWidget

    I have a view based on QListWidget, Now I want to send a mouse double click event to my view to invoke view's mouse double click event.

    Anybody tell me how to implement this function?

    I am using Qt4.3 on XP

    I have tried , qApp->postEvent(myView, [create my new double click event])
    but my View can't get this double clicke event, why?

    my function as below, this event is from one button,
    Qt Code:
    1. void mouseDoubleClickEvent ( QMouseEvent * event )
    2. {
    3. QListWidget* pParent = qobject_cast< QListWidget*>(this->parent());
    4. if ( NULL != pParent )
    5. {
    6. QMouseEvent* pNewMouseEvent = new QMouseEvent(event->type(),event->pos(),
    7. event->button(),event->buttons(),
    8. event->modifiers());
    9. QEvent* pEvent = (QEvent*)(pNewMouseEvent);
    10. if ( NULL != pEvent )
    11. {
    12. qApp->postEvent(pParent,pEvent);
    13. }
    14. //pParent->mouseDoubleClickEvent(event);
    15. }
    16. }
    To copy to clipboard, switch view to plain text mode 


    Thanks in advance

  2. #2
    Join Date
    Oct 2006
    Location
    New Delhi, India
    Posts
    2,467
    Thanks
    8
    Thanked 334 Times in 317 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: how to send a emulated mouse event to QListWidget

    Why are u trying to emulate the doubleclick event ??
    Theres already QWidget::mouseDoubleClickEvent to use ?

  3. #3
    Join Date
    Feb 2006
    Location
    Oslo, Norway
    Posts
    6,264
    Thanks
    36
    Thanked 1,519 Times in 1,389 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows Symbian S60 Maemo/MeeGo

    Default Re: how to send a emulated mouse event to QListWidget

    Qt Code:
    1. qApp->postEvent(pParent->viewport(),pEvent);
    To copy to clipboard, switch view to plain text mode 
    J-P Nurmi

  4. The following user says thank you to jpn for this useful post:

    yxmaomao (22nd July 2008)

  5. #4
    Join Date
    May 2008
    Posts
    58
    Thanks
    2

    Default Re: how to send a emulated mouse event to QListWidget

    Thanks jpn , you are right!

    But I need send this event two times then my list vidget can get a real double click event, I don't know why?

    Maybe you know.

  6. #5
    Join Date
    May 2008
    Posts
    58
    Thanks
    2

    Default Re: how to send a emulated mouse event to QListWidget

    Quote Originally Posted by aamer4yu View Post
    Why are u trying to emulate the doubleclick event ??
    Theres already QWidget::mouseDoubleClickEvent to use ?
    hi, that's my special case

Similar Threads

  1. The event fired by the mouse click on the frame
    By Placido Currò in forum Qt Programming
    Replies: 8
    Last Post: 3rd March 2007, 09:05

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.