added eventFilters and changed the behaviour of the return-key-pressed

This commit is contained in:
nemu
2009-04-20 07:46:50 +00:00
parent 01ee7c0196
commit 61f6fd1b9c
5 changed files with 32 additions and 2 deletions

View File

@@ -44,6 +44,9 @@
*/
PGetPlotDialog::PGetPlotDialog()
{
// setup event filter
installEventFilter(this);
fXRangeLow_lineEdit->setValidator( new QDoubleValidator(fXRangeLow_lineEdit) );
fXRangeUp_lineEdit->setValidator( new QDoubleValidator(fXRangeUp_lineEdit) );
fYRangeLow_lineEdit->setValidator( new QDoubleValidator(fYRangeLow_lineEdit) );
@@ -144,6 +147,29 @@ void PGetPlotDialog::addPlot()
fRunList_lineEdit->setFocus();
}
//----------------------------------------------------------------------------------------------------
/**
* <p>This event filter is filtering out the return key, and if present adds the current plot.
*/
bool PGetPlotDialog::eventFilter( QObject *obj, QEvent *ev )
{
if (obj == this) {
if (ev->type() == QEvent::KeyPress) {
QKeyEvent *k = (QKeyEvent*)ev;
if (k->key() == Qt::Key_Return) {
addPlot();
return true;
} else {
return false;
}
} else {
return false;
}
} else {
return false;
}
}
//----------------------------------------------------------------------------------------------------
// END
//----------------------------------------------------------------------------------------------------