4

I have the following behavior.
I overload focusOutEvent() handler for my widget class. But the handler is called not only, when the widget losses focus, but either on clicking on it. Just like it would be losing focus and then regaining it.

Question one: Is it a bug?
Question two: If not, is there a reasonable way to handling focus losing? -- Slotting all focusChange() signals does not look attractive.

I'm using Qt5.1

masrtis
  • 1,282
  • 17
  • 32
Number47
  • 493
  • 4
  • 14

1 Answers1

0

Name your widgets.

myWidget->setObjectName("MyWidget 1");

myWidget2->setObjectName("MyWidget 2");

Then at the top of your focusOutEvent() and your focusInEvent(), put a helpful but of debugging code:

qDebug() << Q_FUNC_INFO << "called by" << qPrintable(this->objectName());

Now you can see what is causing your issue.

You may also want to dump your object tree, so you can see if you have multiple instances floating around.

QObject::dumpObjectTree();

But call it from your QMainWindow or whatever window is your outermost window.

Hope that helps.

phyatt
  • 18,472
  • 5
  • 61
  • 80