Results 1 to 10 of 10

Thread: mousePressEvent problem

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Dec 2008
    Location
    Istanbul, TURKEY
    Posts
    537
    Thanks
    14
    Thanked 13 Times in 13 Posts
    Qt products
    Qt4
    Platforms
    Windows Android

    Default Re: mousePressEvent problem

    Are you saying to re-order the functions?
    Exactly..Once I've faced with such a problem. And after I replace the regarding functions, it was OK.

  2. #2
    Join Date
    Feb 2010
    Location
    Sydney, Australia
    Posts
    111
    Thanks
    18
    Thanked 5 Times in 5 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: mousePressEvent problem

    I was having what sounds like a similar problem recently where a custom QWidget (comprising QPushButton and QSpinBox) was being added to a QMenu as a QWidgetAction. I wanted a click (or mouseReleaseEvent) from the QPushButton to "activate" the QActionWidget.

    I had to do a little work to get the mouseReleaseEvent to propagate through to the QMenu (using this post). I managed to catch execution in QMenu::activate, but d->mouseDown was not set. I think it had to do with clicking on the QPushButton which was not being considered to be "inside" the QWidgetAction and therefore failing to actually properly activate the QWidgetAction. This is the thread.

    I solved my problem with a simple workaround, but would like to get it working using events properly.

    EDIT: I just had a look at your code snippet again. I think you might need to call mousePressEvent on your base class in void ImageGLView::mousePressEvent(QMouseEvent *event).

    i.e.
    Qt Code:
    1. void ImageGLView::mousePressEvent(QMouseEvent *event)
    2. {
    3. if(FLOATING_DOT == mouseMode){
    4. QPoint currentPos = event->pos();
    5. lastPos = currentPos;
    6. }
    7. QBaseClass::mousePressEvent(event);
    8. }
    To copy to clipboard, switch view to plain text mode 

    EDIT: I take it back - I reread you post and I realised that your mousePressEvent isn't even being called. Is the base class mousePressEvent being called when clicking inside QGLWidget (unlikely)? Is the parent's mousePressEvent being called when you click inside the QGLWidget (should happen under normal circumstances, as far as I understand)?
    Last edited by stefanadelbert; 16th April 2010 at 09:25.

  3. #3
    Join Date
    Sep 2008
    Location
    Falmouth, MA, USA
    Posts
    34
    Thanks
    4
    Thanked 2 Times in 1 Post
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: mousePressEvent problem

    Quote Originally Posted by stefanadelbert View Post
    I was having what sounds like a similar problem recently where a custom QWidget (comprising QPushButton and QSpinBox) was being added to a QMenu as a QWidgetAction. I wanted a click (or mouseReleaseEvent) from the QPushButton to "activate" the QActionWidget.

    I had to do a little work to get the mouseReleaseEvent to propagate through to the QMenu (using this post). I managed to catch execution in QMenu::activate, but d->mouseDown was not set. I think it had to do with clicking on the QPushButton which was not being considered to be "inside" the QWidgetAction and therefore failing to actually properly activate the QWidgetAction. This is the thread.

    I solved my problem with a simple workaround, but would like to get it working using events properly.

    EDIT: I just had a look at your code snippet again. I think you might need to call mousePressEvent on your base class in void ImageGLView::mousePressEvent(QMouseEvent *event).

    i.e.
    Qt Code:
    1. void ImageGLView::mousePressEvent(QMouseEvent *event)
    2. {
    3. if(FLOATING_DOT == mouseMode){
    4. QPoint currentPos = event->pos();
    5. lastPos = currentPos;
    6. }
    7. QBaseClass::mousePressEvent(event);
    8. }
    To copy to clipboard, switch view to plain text mode 

    EDIT: I take it back - I reread you post and I realised that your mousePressEvent isn't even being called. Is the base class mousePressEvent being called when clicking inside QGLWidget (unlikely)? Is the parent's mousePressEvent being called when you click inside the QGLWidget (should happen under normal circumstances, as far as I understand)?
    no, the base class mousePressEvent is NOT being called,or does it appear that the parents mousePressEvent is being called

  4. #4
    Join Date
    Feb 2010
    Location
    Sydney, Australia
    Posts
    111
    Thanks
    18
    Thanked 5 Times in 5 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: mousePressEvent problem

    The parent's mousePressEvent should get called, unless the event is not being passed up for some reason.

    Maybe try reimplementing mouseReleaseEvent in QGLWidget and see if that is called.

Similar Threads

  1. Replies: 8
    Last Post: 16th April 2010, 09:41
  2. mousePressEvent Problem in Qt4
    By hotjava in forum Qt Programming
    Replies: 2
    Last Post: 9th November 2008, 09:29
  3. QGraphicScene MousePressEvent
    By Spitz in forum Qt Programming
    Replies: 3
    Last Post: 16th November 2007, 21:46
  4. MousePressEvent for QTextEdit
    By anju123 in forum Qt Programming
    Replies: 9
    Last Post: 16th August 2007, 06:08
  5. mousePressEvent
    By mickey in forum Newbie
    Replies: 3
    Last Post: 21st March 2006, 15:36

Tags for this Thread

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.