mouseReleaseEvent() not work in QOpenGLWidget....



  • mouseReleaseEvent() not work in QOpenGLWidget....
    i override mouseReleaseEvent() in MyOpenGLWidget which is inherite from QOpenGLWidget, but mouseReleaseEvent is not work.....
    however, mousePressEvent and mouseMoveEvent work...
    anyone know the solution?
    thank you!!!



  • Hi,
    please show the code, as I would say that it does work.
    -Michael.



  • it's simple, just override virtual func mouseReleaseEvent() in MyOpenGLWidget : public QOpenGLWidget


  • Lifetime Qt Champion

    Hi,

    Like @m-sue asked, please show us how you did that. It's easy to sleep an error there for example a wrong or missing argument.



  • The mouse release event does work with a QOpenGLWidget. I use it all the time but I did have a problem with getting a mouse release event if this happened when the mouse was outside the area of the widget.

    If you don't see any events at all it is possible you don't have the mouse events declared properly:

    protected:
    	virtual void mousePressEvent(QMouseEvent *event);
    	virtual void mouseMoveEvent(QMouseEvent *event);
    	virtual void mouseReleaseEvent(QMouseEvent *event);
    
    

    If you are not seeing the mouse release event when the mouse position moves beyond the area of the widget you can change the focus policy in the constructor of your derived class to prevent this from happening:

    	this->setFocusPolicy(Qt::StrongFocus);
    

Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.