PDA

View Full Version : problem reimplementing mouseMoveEvent



jhowland
6th April 2010, 19:04
I have written an application that uses a QGLWidget for stereo image display (Windows XP, QT 2010.01). I am trying to use the mouse to move a synthetic cursor around--in other words, I want to use mouse movements to move a cursor that I will draw in the GL scene. This will let me move a "floating dot" around in the stereo scene.

I have attempted to reimplement mouseMoveEvent--here's the .h file entry



protected:

void initializeGL();
void paintGL();
void mousePressEvent(QMouseEvent *event);
void mouseMoveEvent(QMouseEvent *event);


Here is the mouseMoveEvent:




void ImageGLView::mouseMoveEvent(QMouseEvent *event)
{
if(FLOATING_DOT == mouseMode){
// do something
}
else{
QWidget::mouseMoveEvent(event);
}


}



the problem is that the reimplemented event function never gets called. I have placed breakpoints in it using the debugger (QT Creator) and it never seems to get the event. I have tried clicking to gain mouse context, etc, to no avail. To the best of my ability to tell, my mouseMoveEvent never gets called

I am baffled. The approach seems to work when using other types of widgets--is it the OpenGL nature of it that is causing the problem? I tried to follow the on-line examples, as well as various examples in Blanchette and Summerfield, and I suspect I'm doing something really stupid that I just can't see. The same affect seems to happen with mousePressEvent as well

Thanks in advance for any help

jhowland
6th April 2010, 19:16
a later addition--I tried setting mouse tracking to true, and now I get the events. However, the documentation indicates that I should get events if a mouse button is pressed during a move, and that's what I've been doing. I took out my mousePressEvent handler, in case that was interfering, and it made no difference. So although I can now get events, I don't understand why...

jhowland
6th April 2010, 20:18
Turning on mouse tracking does make the application work. However,I have reimplemented mousePressEvent on the same QGLWidget--and now thatdoesn't work. Same scheme, the mousePressEvent handler never gets called. Is there anything special about QGLWidgets, or stereo that I don't know about?