Results 1 to 2 of 2

Thread: parent widet does not get mouse event.

  1. #1
    Join Date
    Nov 2007
    Posts
    291
    Thanks
    85
    Thanked 1 Time in 1 Post

    Default parent widet does not get mouse event.

    hi
    In the following code ,the mousePressEvent is not executed.does this means that the events first goes to child widgets and then to parents.

    Qt Code:
    1. #include <QtGui>
    2. class Widget : public QMainWindow
    3. {
    4. public:
    5. Widget()
    6. {
    7. QDirModel *model = new QDirModel;
    8. QListView *list =new QListView(this);
    9. list->setModel(model);
    10. this->setCentralWidget(list);
    11. }
    12.  
    13. protected:
    14. void mousePressEvent(QMouseEvent *event)
    15. {
    16. qDebug()<<"press";
    17. }
    18. };
    19. [CENTER][/CENTER]
    20. int main(int argc, char *argv[])
    21. {
    22. QApplication a(argc, argv);
    23. Widget w;
    24. w.show();
    25. return a.exec();
    26. }
    To copy to clipboard, switch view to plain text mode 

  2. #2
    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: parent widet does not get mouse event.

    Quote Originally Posted by babu198649 View Post
    In the following code ,the mousePressEvent is not executed.does this means that the events first goes to child widgets and then to parents.
    That's right. Ignoring the event, however, indicates that the receiver does not want the event. Unwanted events might be propagated to the parent widget. Also, event filters make it possible to catch events of arbitrary receivers.
    J-P Nurmi

  3. The following 2 users say thank you to jpn for this useful post:

    alizadeh91 (27th February 2012), babu198649 (27th July 2008)

Similar Threads

  1. how to send a emulated mouse event to QListWidget
    By yxmaomao in forum Qt Programming
    Replies: 4
    Last Post: 22nd July 2008, 02:49
  2. pass mouse event information to another widget
    By Rooster in forum Qt Programming
    Replies: 5
    Last Post: 12th July 2008, 04:23
  3. Handling Mouse Events of a parent widget
    By dvmorris in forum Qt Programming
    Replies: 2
    Last Post: 28th March 2007, 18:44
  4. 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
  5. Passing event to parent
    By QPissedOff in forum Newbie
    Replies: 1
    Last Post: 26th April 2006, 16:37

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
  •  
Qt is a trademark of The Qt Company.