I have a gui with multiple LineEdits widget. I am trying to determine which lineedit got focus. I know that there is this hasFocus() method but I can't seems to get it to work.

code:
...
QLineEdit *Name_lineEdit = new QLineEdit();
QLineEdit *Pass_lineEdit = new QLineEdit();

Pass_lineEdit->setFocus();

printf("P focus = %d\n\r", Pass_lineEdit->hasFocus());
printf("N focus = %d\n\r", Name_lineEdit->hasFocus());

app.exec();

Output return
P focus = 0
N focus = 0

Why is Pass_lineEdit->hasFocus() return 0? I would expect it to be 1
Is there any way to determine which widget got focus without having to go through each widget focus property?