summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAndy Shaw <andy.shaw@digia.com>2013-04-17 09:31:49 +0200
committerThe Qt Project <gerrit-noreply@qt-project.org>2013-04-21 02:01:29 +0200
commitf78842abe429dc9b42fd15dc8e9e842ab72dcf2b (patch)
tree4bf0fc28b3890cd217d43521c20014f008bb6ae7
parent51ee309a7946f5377e26da23ae52171711e59461 (diff)
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>
-rw-r--r--src/widgets/widgets/qabstractspinbox.cpp1
-rw-r--r--tests/auto/widgets/widgets/qspinbox/tst_qspinbox.cpp11
2 files changed, 11 insertions, 1 deletions
diff --git a/src/widgets/widgets/qabstractspinbox.cpp b/src/widgets/widgets/qabstractspinbox.cpp
index 765dcb8981..288375fe28 100644
--- a/src/widgets/widgets/qabstractspinbox.cpp
+++ b/src/widgets/widgets/qabstractspinbox.cpp
@@ -990,6 +990,7 @@ void QAbstractSpinBox::keyPressEvent(QKeyEvent *event)
selectAll();
event->ignore();
emit editingFinished();
+ emit d->edit->returnPressed();
return;
#ifdef QT_KEYPAD_NAVIGATION
diff --git a/tests/auto/widgets/widgets/qspinbox/tst_qspinbox.cpp b/tests/auto/widgets/widgets/qspinbox/tst_qspinbox.cpp
index 89b7bc6790..a64b34c56a 100644
--- a/tests/auto/widgets/widgets/qspinbox/tst_qspinbox.cpp
+++ b/tests/auto/widgets/widgets/qspinbox/tst_qspinbox.cpp
@@ -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"