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.
{
if(FLOATING_DOT == mouseMode){
QPoint currentPos
= event
->pos
();
lastPos = currentPos;
}
QBaseClass::mousePressEvent(event);
}
void ImageGLView::mousePressEvent(QMouseEvent *event)
{
if(FLOATING_DOT == mouseMode){
QPoint currentPos = event->pos();
lastPos = currentPos;
}
QBaseClass::mousePressEvent(event);
}
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)?
Bookmarks