Results 1 to 2 of 2

Thread: problem about mouse button events

  1. #1
    Join Date
    Jun 2006
    Location
    Vietnam
    Posts
    59
    Thanks
    17
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default problem about mouse button events

    Hello.

    I have a small problem about mouse button event. This is a simple program:

    Qt Code:
    1. // ...
    2.  
    3. void MyWidget::mousePressEvent(QMouseEvent *e)
    4. {
    5. qWarning("mousePressEvent");
    6. QWidget::mousePressEvent(e);
    7. }
    8.  
    9. void MyWidget::mouseReleaseEvent(QMouseEvent *e)
    10. {
    11. qWarning("mouseReleaseEvent");
    12. QWidget::mouseReleaseEvent(e);
    13. }
    14.  
    15. // ...
    To copy to clipboard, switch view to plain text mode 

    When I press a left mouse button, and keep it. I drag to another position and press the middle the button (at this time, both left and middle mouse button are pressed because left mouse button is kept before), and after that, I release the left mouse button.

    But why the system only write the message output:
    mousePressEvent
    It is mean that the mouseReleaseEvent isn't catched.

    Please tell me how to solve this problem how to catch mouseReleaseEvent in this case. Thanks.

  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: problem about mouse button events

    Could you reproduce the problem with the following code?

    Qt Code:
    1. #include <QtGui>
    2.  
    3. class Widget : public QWidget {
    4. public:
    5. Widget() : QWidget(){}
    6. protected:
    7. void mousePressEvent(QMouseEvent *me){
    8. qDebug("PRESS");
    9. }
    10. void mouseReleaseEvent(QMouseEvent *me){
    11. qDebug("RELEASE");
    12. }
    13. };
    14.  
    15. int main(int argc, char **argv){
    16. QApplication app(argc, argv);
    17. Widget w;
    18. w.show();
    19. return app.exec();
    20. }
    To copy to clipboard, switch view to plain text mode 

Similar Threads

  1. Replies: 3
    Last Post: 4th December 2007, 11:04
  2. How to ignore Button-Events in Qtopia?
    By Helmut Hönig in forum Qt for Embedded and Mobile
    Replies: 0
    Last Post: 5th July 2007, 14:24
  3. QPushButton:: Handle right mouse button events. Easyway?
    By Harvey West in forum Qt Programming
    Replies: 6
    Last Post: 28th February 2007, 17:56
  4. mouse moving don't produce mouse events
    By coralbird in forum Qt Programming
    Replies: 1
    Last Post: 13th September 2006, 07:13
  5. QStackerWidget and mouse events
    By high_flyer in forum Qt Programming
    Replies: 3
    Last Post: 25th April 2006, 20:25

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.