DataPlayer/ChaosDataPlayer/FilterForm.cpp
2022-07-30 11:50:01 +08:00

57 lines
1.4 KiB
C++
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

#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();
}
}