Mouse cursor changes to waiting then stays like it, why?
-
In my application I have:
bool clsXMLnode::eventFilter(QObject* pobjObject, QEvent* pobjEvent) { QWidget* pobjWidget = static_cast<QWidget*>(pobjObject); if ( pobjWidget != nullptr ) { QString strID = pobjWidget->accessibleName(); if ( strID.isEmpty() != true ) { clsXMLnode* pobjNode = clsXMLnode::pobjGetNodeById(strID); if ( pobjNode != nullptr ) { QEvent::Type evtType = pobjEvent->type(); if ( evtType == QEvent::Move ) { QMoveEvent* pobjMove = static_cast<QMoveEvent*>(pobjEvent); QPoint ptNew = pobjMove->pos(); int intX = ptNew.x(), intY = ptNew.y(); if ( intX >= 0 && intY >= 0 ) { setAttribute(clsXMLnode::mscszAttrPoint ,QString::number(intX) + clsXMLnode::msccParamDelimiter + QString::number(intY)); } } else if ( evtType == QEvent::Resize ) { QResizeEvent* pobjResize = static_cast<QResizeEvent*>(pobjEvent); QSize szNew = pobjResize->size(); if ( szNew.isValid() == true ) { pobjNode->resize(szNew); } } else { //Dump event static int intCounter; qDebug() << __LINE__ << evtType << ++intCounter; } } } } return QObject::eventFilter(pobjObject, pobjEvent); }
The eventfilter handles the windows events I am interested in, in this case Move and Resize. Whatever happens I always return with:
return QObject::eventFilter(pobjObject, pobjEvent);
For some reason which I don't currently understand when I move the window the cursor is changed to a waiting cursor and doesn't change back to normal. This does not happen when the window is resized.
I can see that the qDebug() after:
//Dump event
Gets repeatedly called after the move event with a Paint event. It doesn't stop, this does not happen on a Resize event.
Is there something else I'm supposed to call when the window move event occurs?
I've tried calling:
QApplication::setOverrideCursor(Qt::ArrowCursor);
Before returning from the eventFilter after the Move event has been handled, no difference.
[Edit] I know now why it is doing this, my function setAttribute takes the point and if the node has a widget, which the window does it calls the widgets setGeometry with the modify position, this then triggers the resize event again. I will try to prevent this recursion by adding a flag to the function which is set before it sets the widget geometry and clear after and then check in the eventFilter function for this flag, it it is set it will take no action.
This didn't work!
Question, if setGeometry on a widget causes the eventFilter to be called again what is the correct way to handle a Move event without entering a recursive loop ?