Results 1 to 7 of 7

Thread: why QListWidget can't get QEvent::MouseButtonPress?

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Apr 2008
    Posts
    44
    Thanks
    21
    Qt products
    Qt4 Qt/Embedded
    Platforms
    Unix/X11

    Default Re: why QListWidget can't get QEvent::MouseButtonPress?

    the other method:
    I Reimplement mousePressEvent(), the code as following:
    the code in .h:
    Qt Code:
    1. void mousePressEvent(QMouseEvent *event);
    To copy to clipboard, switch view to plain text mode 
    the code in .cpp:
    Qt Code:
    1. void ProgramList::mousePressEvent(QMouseEvent *event)
    2. {
    3. QWidget::mousePressEvent(event);
    4. if( )//the condition:the position is in the List
    5. {
    6. event->ignore();
    7. }
    8. else event->accept();
    9. }
    To copy to clipboard, switch view to plain text mode 

    Then i find the function "mousePressEvent" don't excute when i click the list ; but it excute when i click the Label.
    There must be something wrong in my program. it's so nice for you to point it out and give me the correct code. thanks very much.

  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: why QListWidget can't get QEvent::MouseButtonPress?

    installing event filter on a litwidget's viewport should fix you problem.
    use my example in prev.post.
    Qt Assistant -- rocks!
    please, use tags [CODE] & [/CODE].

  3. The following user says thank you to spirit for this useful post:

    to_guliang (13th May 2009)

Similar Threads

  1. QListWidget transparent background or pixmap
    By wdezell in forum Qt Programming
    Replies: 6
    Last Post: 6th March 2009, 17:53
  2. Segmentation Faul using addItem (QListWidget)
    By gnusar in forum Qt Programming
    Replies: 3
    Last Post: 8th November 2008, 09:27
  3. how to sync a QTreeWidget and a QListWidget?
    By zl2k in forum Qt Programming
    Replies: 2
    Last Post: 5th September 2008, 20:55
  4. QListWidget Problem
    By pmabie in forum Qt Programming
    Replies: 1
    Last Post: 7th October 2007, 06:52
  5. Replies: 13
    Last Post: 15th December 2006, 11:52

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.