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?
// --------------------------------------------------------------------
{
Q_OBJECT
protected:
};
this->selectAll(); // THIS DOESN'T WORK
//this->clear(); // <-- THIS WORKS!
}
// --------------------------------------------------------------------
class MyLineEdit : public QLineEdit
{
Q_OBJECT
protected:
void focusInEvent(QFocusEvent *);
};
void MyLineEdit::focusInEvent(QFocusEvent *e) {
this->selectAll(); // THIS DOESN'T WORK
//this->clear(); // <-- THIS WORKS!
}
To copy to clipboard, switch view to plain text mode
Bookmarks