-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinputdialog.cpp
More file actions
executable file
·42 lines (36 loc) · 1.36 KB
/
inputdialog.cpp
File metadata and controls
executable file
·42 lines (36 loc) · 1.36 KB
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
#include "inputdialog.h"
InputDialog::InputDialog(QWidget *parent): QWidget(parent)
{
setup();
}
void InputDialog::setup()
{
startValuesBox = new QSpinBox(this);
endValuesBox = new QSpinBox(this);
QDialogButtonBox* finishBox{new QDialogButtonBox(QDialogButtonBox::Ok | QDialogButtonBox::Cancel)};
QObject::connect(finishBox, SIGNAL(accepted()), this, SLOT(checkAllValues()));
QObject::connect(finishBox, SIGNAL(rejected()), this, SLOT(close()));
QGridLayout* mainLayout{new QGridLayout(this)};
mainLayout->addWidget(new QLabel("Xuất phát: "), 0, 0);
mainLayout->addWidget(startValuesBox, 0, 1);
mainLayout->addWidget(new QLabel("Đích: "), 1, 0);
mainLayout->addWidget(endValuesBox, 1, 1);
mainLayout->addWidget(finishBox, 2, 0, 1, 2);
setLayout(mainLayout);
}
void InputDialog::setValue(int maxInt)
{
startValuesBox->setRange(1, maxInt);
endValuesBox->setRange(1, maxInt);
setWindowTitle("Nhập giá trị đầu cuối");
show();
}
void InputDialog::checkAllValues()
{
if (startValuesBox->value() == endValuesBox->value()) QMessageBox::warning(this, "Giá trị không phù hợp", "Đỉnh xuất phát và đích trùng nhau, vui lòng chọn lại");
else
{
emit gotAllValues(startValuesBox->value(), endValuesBox->value());
close();
}
}