The focus out event could look for example something like this:
{
// check validator state
int pos = 0;
QValidator::State state
= validator
()->validate
(text
(), pos
);
{
// keep focus if intermediate
setFocus();
}
else
{
// otherwise call base class implementation and let it
// handle focus out actions (so cursor stops blinking etc.)
}
}
void MyLineEdit::focusOutEvent(QFocusEvent* event)
{
// check validator state
int pos = 0;
QValidator::State state = validator()->validate(text(), pos);
if (state == QValidator::Intermediate)
{
// keep focus if intermediate
setFocus();
}
else
{
// otherwise call base class implementation and let it
// handle focus out actions (so cursor stops blinking etc.)
QLineEdit::focusOutEvent(event);
}
}
To copy to clipboard, switch view to plain text mode
If you have difficulties in subclassing QLineEdit, I suggest you to switch back to your favourite C++ book and learn the secrects of inheritance..
Bookmarks