+ restore selected numbers in input field after showing it, select numbers if widget gets focus by Tab/Backtab/Shortcut

This commit is contained in:
wmayer 2014-06-10 11:34:23 +02:00
parent 39e412da56
commit f867733499
2 changed files with 14 additions and 0 deletions

View File

@ -460,7 +460,20 @@ void InputField::showEvent(QShowEvent * event)
{
QLineEdit::showEvent(event);
bool selected = this->hasSelectedText();
updateText(actQuantity);
if (selected)
selectNumber();
}
void InputField::focusInEvent(QFocusEvent * event)
{
if (event->reason() == Qt::TabFocusReason ||
event->reason() == Qt::BacktabFocusReason ||
event->reason() == Qt::ShortcutFocusReason) {
if (!this->hasSelectedText())
selectNumber();
}
}
void InputField::keyPressEvent(QKeyEvent *event)

View File

@ -157,6 +157,7 @@ protected Q_SLOTS:
protected:
virtual void showEvent(QShowEvent * event);
virtual void focusInEvent(QFocusEvent * event);
virtual void keyPressEvent(QKeyEvent * event);
virtual void wheelEvent(QWheelEvent * event);
virtual void contextMenuEvent(QContextMenuEvent * event);