Results 1 to 3 of 3

Thread: Is there any easy way to get all child control's mouse click event??

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

    Default Is there any easy way to get all child control's mouse click event??

    Guess there is a widget[named as A] which includes some child widgets
    and these child widgets maybe include some others child widgets, and so on

    now I want to A to get all the mouse click event , no matter which subcontrol use click on.

    Does anyone know an easy way to implement this ?
    Last edited by yxmaomao; 4th August 2008 at 05:53.

  2. #2
    Join Date
    Aug 2008
    Location
    Ukraine, Krivoy Rog
    Posts
    1,963
    Thanked 370 Times in 336 Posts
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: Is there any easy way to get all child control's mouse click event??

    you can use
    Qt Code:
    1. void QObject::installEventFilter ( QObject * filterObj )
    To copy to clipboard, switch view to plain text mode 
    read more in Assistant, it has an exapmle.

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

    Default Re: Is there any easy way to get all child control's mouse click event??

    yes, I got it, should be like this:
    Qt Code:
    1. QList<QWidget*> widgets = qFindChildren<QWidget*>(this);
    2. foreach(QWidget *widget, widgets)
    3. widget->installEventFilter(this);
    4. installEventFilter(this);
    To copy to clipboard, switch view to plain text mode 
    then we can install event filter for all children, that's perfect!
    good luck to every one who want to get this.
    Last edited by jpn; 4th August 2008 at 10:34. Reason: missing [code] tags

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
  2. mouse click event
    By vijay anandh in forum Qt Programming
    Replies: 1
    Last Post: 1st May 2006, 09:24

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.