I'm having trouble selecting all the text in a QLineEdit control inside an eventFilter.

In a QDialog, I want to select all text in a QLineEdit control when a user tabs into it. My eventFilter recognizes the control but doesn't select.

Qt Code:
  1. bool AddMainPage::eventFilter( QObject* pObj, QEvent* pEvent )
  2. {
  3. if ( pEvent->type() == QEvent::FocusIn )
  4. {
  5. if ( pObj == ui.ipAddrEdt ) // ipAddrEdt has focus at this point
  6. {
  7. ui.ipAddrEdt->selectAll();
  8. ui.ipAddrEdt->setCursorPosition( 0 );
  9. return true;
  10. }
  11. ...
To copy to clipboard, switch view to plain text mode 
I'm not sure that I'm going about this in the correct way either. I don't want to selectAll() when the user uses the mouse to click into the control, only when it's tabbed into. I know that I'm dealing with 2 different events here; QEvent::FocusIn and QEvent::KeyPress.

Does anyone have any suggestions on how best to handle this situation?