-
Notifications
You must be signed in to change notification settings - Fork 0
/
collecting.cpp
44 lines (39 loc) · 1.15 KB
/
collecting.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
#include "collecting.h"
#include "ui_collecting.h"
#include <QKeyEvent>
#include <QShortcut>
collecting::collecting(QString product,QWidget *parent) :
QDialog(parent),
ui(new Ui::collecting)
{
ui->setupUi(this);
setWindowTitle(tr("collecting"));
QValidator *validator = new QIntValidator(1, 2147483646, this);
ui->lineEdit->setValidator(validator);
ui->label->setText(product);
setWindowFlags(Qt::WindowTitleHint);
QShortcut *shortcut1 = new QShortcut(QKeySequence(Qt::Key_Return),this);//Enter button
QShortcut *shortcut2 = new QShortcut(QKeySequence(Qt::Key_Enter),this);//Enter button
connect(shortcut1, SIGNAL(activated()), this, SLOT(on_accept_clicked()));
connect(shortcut2, SIGNAL(activated()), this, SLOT(on_accept_clicked()));
}
collecting::~collecting()
{
delete ui;
}
void collecting::on_cancel_clicked()
{
everything=0;
new_amount=0;
close();
}
void collecting::on_accept_clicked()
{
new_amount = ui->lineEdit->text().toInt();
everything=ui->checkBox->isChecked();
close();
}
void collecting::keyPressEvent(QKeyEvent *e) {
if(e->key() == Qt::Key_Escape)
on_cancel_clicked();
}