Results 1 to 3 of 3

Thread: QTreeWidget and eventFilter

  1. #1
    Join Date
    Jul 2009
    Posts
    11
    Thanks
    3

    Smile QTreeWidget and eventFilter

    I placed a QTreeWidget on a QDialog. And I want to get QTreeWiget's mouse press event,so I use eventFilter like this:
    in QDialog's construction
    Qt Code:
    1. ui.m_pTreeWidget->installEventFilter( this );
    To copy to clipboard, switch view to plain text mode 
    in the eventFilter() function:
    Qt Code:
    1. bool ***::(QObject *pTarget, QEvent *pEvent)
    2. {
    3. if( pTarget == ui.m_pTreeWidget )
    4. {
    5. if( pEvent->type() == QEvent::MouseButtonPress )
    6. {
    7. return false;
    8. }
    9. }
    10. return QDialog::eventFilter( pTarget, pEvent );
    11. }
    To copy to clipboard, switch view to plain text mode 
    But I can't get the mouse press event,why?
    Thanks a lot !

  2. #2
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: QTreeWidget and eventFilter

    Filter events on the tree's viewport() and not on the view itself.
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


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

    csernai.csaba (28th June 2010), luoyes (5th November 2009)

  4. #3
    Join Date
    Jul 2009
    Posts
    11
    Thanks
    3

    Default Re: QTreeWidget and eventFilter

    Quote Originally Posted by wysota View Post
    Filter events on the tree's viewport() and not on the view itself.
    Thank you! It works.

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.