I have subclassed QLineEdit in order to handle a focus event, and I would like all existing text to be highlighted as soon as I click in the textbox. The selectAll() method does not work. What am I missing?

Qt Code:
  1. // --------------------------------------------------------------------
  2. class MyLineEdit : public QLineEdit
  3. {
  4. Q_OBJECT
  5.  
  6. protected:
  7. void focusInEvent(QFocusEvent *);
  8.  
  9. };
  10.  
  11. void MyLineEdit::focusInEvent(QFocusEvent *e) {
  12.  
  13. this->selectAll(); // THIS DOESN'T WORK
  14. //this->clear(); // <-- THIS WORKS!
  15.  
  16. }
To copy to clipboard, switch view to plain text mode