57 lines
1.4 KiB
C++
57 lines
1.4 KiB
C++
|
|
#include "FilterForm.h"
|
|||
|
|
#include "ui_FilterForm.h"
|
|||
|
|
#include "QMessageBox"
|
|||
|
|
#include <qvalidator.h>
|
|||
|
|
#include "msgbox.h"
|
|||
|
|
|
|||
|
|
FilterForm::FilterForm(QWidget *parent) :
|
|||
|
|
BaseWgt(parent),
|
|||
|
|
ui(new Ui::FilterForm)
|
|||
|
|
{
|
|||
|
|
ui->setupUi(this);
|
|||
|
|
resize(500,320);
|
|||
|
|
setWindowTitle("滤波");
|
|||
|
|
connect(ui->Btn_OK, SIGNAL(clicked()), this, SLOT(SetFilter()));
|
|||
|
|
connect(ui->Btn_Cancel, SIGNAL(clicked()), this, SLOT(Cancel()));
|
|||
|
|
QRegExp rx("[0-9\.]+$");
|
|||
|
|
QRegExpValidator *validator = new QRegExpValidator(rx, this);
|
|||
|
|
ui->lineEdit->setValidator(validator);
|
|||
|
|
ui->lineEdit_2->setValidator(validator);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
FilterForm::~FilterForm()
|
|||
|
|
{
|
|||
|
|
delete ui;
|
|||
|
|
}
|
|||
|
|
void FilterForm::Cancel()
|
|||
|
|
{
|
|||
|
|
this->close();
|
|||
|
|
}
|
|||
|
|
void FilterForm::SetFilter()
|
|||
|
|
{
|
|||
|
|
QString Xstart = ui->lineEdit->text();
|
|||
|
|
QString Xend = ui->lineEdit_2->text();
|
|||
|
|
|
|||
|
|
if((Xstart.length() == 0 && Xend.length() == 0))
|
|||
|
|
{
|
|||
|
|
MyMsgBox(QMessageBox::Warning,"警告","请输入正确信息!");
|
|||
|
|
return;
|
|||
|
|
}
|
|||
|
|
if(Xstart.toInt() > Xend.toInt())
|
|||
|
|
{
|
|||
|
|
MyMsgBox(QMessageBox::Warning,"警告","请输入正确信息!");
|
|||
|
|
return;
|
|||
|
|
}
|
|||
|
|
emit sgSetFilter(Xstart+","+Xend);
|
|||
|
|
this->close();
|
|||
|
|
}
|
|||
|
|
void FilterForm::keyPressEvent(QKeyEvent *event)
|
|||
|
|
{
|
|||
|
|
//Enter事件好像这两个都要写,只写event->key() == Qt::Key_Enter,无法实现
|
|||
|
|
if (event->key() == Qt::Key_Enter || event->key() == Qt::Key_Return)
|
|||
|
|
{
|
|||
|
|
SetFilter();
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|