Results 1 to 4 of 4

Thread: How to catch MouseBottonPress for QListWidget

Hybrid View

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

    Default Re: How to catch MouseBottonPress for QListWidget

    Try installing the event filter on the view port.
    Qt Code:
    1. installEventFilter(kf);
    2. viewport()->installEventFilter(kf);
    To copy to clipboard, switch view to plain text mode 
    J-P Nurmi

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

    Levon Nikoghosyan (2nd October 2006), Trasmeister (2nd October 2006)

  3. #2
    Join Date
    Sep 2006
    Posts
    6
    Qt products
    Qt4
    Platforms
    Windows
    Thanks
    1

    Default Re: How to catch MouseBottonPress for QListWidget

    Was wrestling with the same problem with QTableWidget this morning! Thanks!

  4. #3
    Join Date
    Sep 2006
    Posts
    10
    Qt products
    Qt3 Qt4 Qt/Embedded
    Platforms
    Windows
    Thanks
    4
    Thanked 1 Time in 1 Post

    Default Re: How to catch MouseBottonPress for QListWidget

    // OBJECT_NAME means, your instance name of the looking object
    // for example:- QTextEdit* sampleEdit = new QTextEdit()
    // watched == sampleEdit

    if( ( watched == OBJECT_NAME ) && ( e->type()==QEvent::MouseButtonPress ) )
    {
    QMouseEvent *mousePress = (QMouseEvent*)e;

    if ( (mousePress->button() == Qt::LeftButton) || (mousePress->button() == Qt::LeftButton) )
    {
    // do your code //
    return true;
    }
    }

    I think the above code will help you regarding MOUSE PRESS EVENT with QListWidget.

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.