-
Notifications
You must be signed in to change notification settings - Fork 0
/
multipleinputdialog.cpp
38 lines (29 loc) · 1.26 KB
/
multipleinputdialog.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
#include "multipleinputdialog.h"
MultipleInputDialog::MultipleInputDialog(QStringList pLabels, QWidget *parent) : QDialog(parent){
setLayout(pLabels);
}
void MultipleInputDialog::setLayout(QStringList pLabels){
mMainLayout = new QFormLayout(this);
foreach(QString label, pLabels) {
QLineEdit* lineEdit = new QLineEdit(this);
mLineEditFields.push_back(lineEdit);
mMainLayout->addRow(label, lineEdit);
}
mButtonBox = new QDialogButtonBox(QDialogButtonBox::Ok |
QDialogButtonBox::Cancel, Qt::Horizontal, this);
mMainLayout->addRow(mButtonBox);
connect(mButtonBox, SIGNAL(accepted()), this, SLOT(accept()));
connect(mButtonBox, SIGNAL(rejected()), this, SLOT(reject()));
}
QStringList MultipleInputDialog::getTexts(QStringList pLabels, QWidget *parent, QLineEdit::EchoMode echo,
Qt::WindowFlags flags,Qt::InputMethodHints inputMethodHints){
MultipleInputDialog* multipleDialog = new MultipleInputDialog(pLabels,parent);
QStringList lines;
if (multipleDialog->exec() == QDialog::Accepted){
foreach(QLineEdit* lineEdit, multipleDialog->mLineEditFields){
lines << lineEdit->text();
}
}
qDebug()<<lines;
return lines;
}