Name your widgets.
myWidget->setObjectName("MyWidget 1"); myWidget2->setObjectName("MyWidget 2");
Then at the top of your focusOutEvent() and your focusInEvent() put some useful but debugging code:
qDebug() << Q_FUNC_INFO << "called by" << qPrintable(this->objectName());
Now you can see what causes your problem.
You can also drop the object tree so that you can see that there are several instances around you.
QObject::dumpObjectTree();
But call it from your QMainWindow or any other window - this is your outermost window.
Hope this helps.
source share