-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathnewproduct.cpp
63 lines (53 loc) · 1.42 KB
/
newproduct.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
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
#include "newproduct.h"
#include "ui_newproduct.h"
#include <QtWidgets>
#include <QApplication>
#include <QKeyEvent>
#include <QShortcut>
newproduct::newproduct( QWidget *parent) :
QDialog(parent),
ui(new Ui::newproduct)
{
ui->setupUi(this);
setWindowTitle(tr("Adding new product"));
QValidator *validator = new QIntValidator(1, 2147483646, this);
ui->i->setValidator(validator);
ui->p->setValidator(validator);
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_add_clicked()));
connect(shortcut2, SIGNAL(activated()), this, SLOT(on_add_clicked()));
}
newproduct::~newproduct()
{
delete ui;
}
void newproduct::on_add_clicked()
{
accepted=TRUE;
quantiny=ui->i->text();
name=ui->np->text();
place=ui->m->text();
condition=ui->s->text();
group1=ui->g1->text();
group2=ui->g2->text();
PLU=ui->p->text();
ui->i->clear();
ui->np->clear();
ui->m->clear();
ui->s->clear();
ui->g1->clear();
ui->g2->clear();
ui->p->clear();
close();
}
void newproduct::on_cancel_clicked()
{
accepted=FALSE;
close();
}
void newproduct::keyPressEvent(QKeyEvent *e) {
if(e->key() == Qt::Key_Escape)
on_cancel_clicked();
}