Ensure the QLineEdit::returnPressed() signal is still emitted

The signal needs to be emitted directly as the event is not passed to
the QLineEdit if the QSpinBox gets the Key_Return. Since this signal
may be relied upon then we ensure it is emitted directly.

Change-Id: I17cdec62c9f995bacfd7d3cc66d6324f26c84c67
Reviewed-by: Stephen Kelly <stephen.kelly@kdab.com>
bb10
Andy Shaw 2013-04-17 09:31:49 +02:00 committed by The Qt Project
parent 51ee309a79
commit f78842abe4
2 changed files with 11 additions and 1 deletions

View File

@ -990,6 +990,7 @@ void QAbstractSpinBox::keyPressEvent(QKeyEvent *event)
selectAll();
event->ignore();
emit editingFinished();
emit d->edit->returnPressed();
return;
#ifdef QT_KEYPAD_NAVIGATION

View File

@ -138,7 +138,7 @@ private slots:
void integerOverflow();
void taskQTBUG_5008_textFromValueAndValidate();
void lineEditReturnPressed();
public slots:
void valueChangedHelper(const QString &);
void valueChangedHelper(int);
@ -1044,5 +1044,14 @@ void tst_QSpinBox::integerOverflow()
QCOMPARE(sb.value(), INT_MIN);
}
void tst_QSpinBox::lineEditReturnPressed()
{
SpinBox spinBox;
QSignalSpy spyCurrentChanged(spinBox.lineEdit(), SIGNAL(returnPressed()));
spinBox.show();
QTest::keyClick(&spinBox, Qt::Key_Return);
QCOMPARE(spyCurrentChanged.count(), 1);
}
QTEST_MAIN(tst_QSpinBox)
#include "tst_qspinbox.moc"