+ (void)obj;
+
+ if (event->type() == QEvent::KeyPress) {
+ keyEvent = static_cast<QKeyEvent*>(event);
+ if (keyEvent->key() == Qt::Key_Enter ||
+ keyEvent->key() == Qt::Key_Return) {
+ close();
+ return true;
+ }
+ }
+
+ return false;
+}
+
+void Popup::show()
+{
+ QLineEdit* le;
+
+ QWidget::show();
+
+ // We want to close the popup when the Enter key was
+ // pressed and the first editable widget had focus.
+ if ((le = this->findChild<QLineEdit*>())) {
+
+ // For combo boxes we need to hook into the parent of
+ // the line edit (i.e. the QComboBox). For edit boxes
+ // we hook into the widget directly.
+ if (le->parent()->metaObject()->className() ==
+ this->metaObject()->className())
+ le->installEventFilter(this);
+ else
+ le->parent()->installEventFilter(this);
+
+ le->selectAll();
+ le->setFocus();
+ }